From unknown Thu Jun 19 14:03:13 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#28156 <28156@debbugs.gnu.org> To: bug#28156 <28156@debbugs.gnu.org> Subject: Status: Emacs quietly munges symlink contents Reply-To: bug#28156 <28156@debbugs.gnu.org> Date: Thu, 19 Jun 2025 21:03:13 +0000 retitle 28156 Emacs quietly munges symlink contents reassign 28156 emacs submitter 28156 Paul Eggert severity 28156 normal tag 28156 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 06:28:23 2017 Received: (at submit) by debbugs.gnu.org; 20 Aug 2017 10:28:23 +0000 Received: from localhost ([127.0.0.1]:46101 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djNSw-0007KD-Ps for submit@debbugs.gnu.org; Sun, 20 Aug 2017 06:28:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56291) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djNSu-0007Jz-0S for submit@debbugs.gnu.org; Sun, 20 Aug 2017 06:28:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djNSn-0007Bj-9k for submit@debbugs.gnu.org; Sun, 20 Aug 2017 06:28:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1djNSn-0007Bb-5x for submit@debbugs.gnu.org; Sun, 20 Aug 2017 06:28:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47262) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djNSl-00074W-Gv for bug-gnu-emacs@gnu.org; Sun, 20 Aug 2017 06:28:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djNSi-0007Au-8W for bug-gnu-emacs@gnu.org; Sun, 20 Aug 2017 06:28:11 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:48874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1djNSh-0007AZ-T7 for bug-gnu-emacs@gnu.org; Sun, 20 Aug 2017 06:28:08 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 794411608A4; Sun, 20 Aug 2017 03:28:06 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id M9LfqvXmH0wX; Sun, 20 Aug 2017 03:28:05 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5A39116088A; Sun, 20 Aug 2017 03:28:05 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wot3QFsHQiju; Sun, 20 Aug 2017 03:28:05 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 30E09160882; Sun, 20 Aug 2017 03:28:05 -0700 (PDT) To: Emacs bug reports and feature requests From: Paul Eggert Subject: Emacs quietly munges symlink contents Organization: UCLA Computer Science Department Message-ID: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> Date: Sun, 20 Aug 2017 03:28:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2AB0D6EE10F96C31D6D9FEDB" Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit Cc: Michael Albinus X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) This is a multi-part message in MIME format. --------------2AB0D6EE10F96C31D6D9FEDB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Tags: patch The attached patch fixes some Emacs behavior that disagrees with the=20 documentation. Although the user manual says that make-symbolic-link "do= es not expand the argument TARGET", Emacs expands leading "~" in the target.= Also,=20 file-symlink-p quietly munges symlink contents if they appear to be a Tra= mp file=20 name. This behavior makes it impossible to write Emacs code that deals wi= th=20 arbitrary local symbolic links, and Emacs mishandles copying of some syml= inks=20 for this reason. At the operating system level, symlink targets are merel= y=20 strings, and are not file names that are interpreted (any interpretation = occurs=20 later, only when the symlinks are followed), and Emacs should be consiste= nt with=20 that. It strikes me that a similar change probably needs to be made to Tramp, s= o that=20 remote symlinks also can be arbitrary strings too. However, that's outsid= e my=20 expertise so this patch affects only local symlink contents. --------------2AB0D6EE10F96C31D6D9FEDB Content-Type: text/x-patch; name="0001-Do-not-munge-contents-of-local-symbolic-links.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Do-not-munge-contents-of-local-symbolic-links.patch" =46rom faf68f4979509cd61b5f666479b66ec5b37594d6 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 20 Aug 2017 03:13:52 -0700 Subject: [PATCH] Do not munge contents of local symbolic links This lets Emacs deal with arbitrary local symlinks without mishandling their contents. For example, (progn (shell-command "ln -fs '~' 'x'") (rename-file "x" "/tmp/x")) now consistently creates a symbolic link from '/tmp/x' to '~'. Formerly, it did that only if the working directory was on the same filesystem as /tmp; otherwise, it expanded the '~' to the user's home directory. * etc/NEWS: Document the change. * src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the target, and look for special constructs only in the new link name, not the target. (emacs_readlinkat): Do not preprend "/:" to the link target if it starts with "/" and contains ":" before NUL. * test/lisp/net/tramp-tests.el (tramp-test21-file-links): Adjust to new behavior. * test/src/fileio-tests.el (try-link): Rename from try-char, and accept a string instead of a char. All uses changed. (fileio-tests--symlink-failure): Also test leading ~, and "/:", to test the new behavior. --- etc/NEWS | 8 ++++++++ src/fileio.c | 18 ------------------ test/lisp/net/tramp-tests.el | 9 ++++++--- test/src/fileio-tests.el | 21 ++++++++++----------- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7774d75..104ee04 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1204,6 +1204,14 @@ instead of to utf-8. Before this change, Emacs wo= uld sometimes mishandle file names containing these control characters. =20 +++ +** 'file-attributes', 'file-symlink-p' and 'make-symbolic-link' no +longer quietly mutate the target of a local symbolic link. In +particular, 'file-attributes' and 'file-symlink-p' no longer prepend +"/:" to some targets of local symbolic links, and 'make-symbolic-link' +no longer expands '~' at the start of a link target. This change lets +Emacs access and copy arbitrary local symbolic links. + ++++ ** Module functions are now implemented slightly differently; in particular, the function 'internal--module-call' has been removed. Code that depends on undocumented internals of the module system might diff --git a/src/fileio.c b/src/fileio.c index f954ac1..ce243c3 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2423,21 +2423,8 @@ This happens for interactive use with M-x. */) Lisp_Object encoded_target, encoded_linkname; =20 CHECK_STRING (target); - /* If the link target has a ~, we must expand it to get - a truly valid file name. Otherwise, do not expand; - we want to permit links to relative file names. */ - if (SREF (target, 0) =3D=3D '~') - target =3D Fexpand_file_name (target, Qnil); - linkname =3D expand_cp_target (target, linkname); =20 - /* If the file name has special constructs in it, - call the corresponding file handler. */ - handler =3D Ffind_file_name_handler (target, Qmake_symbolic_link); - if (!NILP (handler)) - return call4 (handler, Qmake_symbolic_link, target, - linkname, ok_if_already_exists); - /* If the new link name has special constructs in it, call the corresponding file handler. */ handler =3D Ffind_file_name_handler (linkname, Qmake_symbolic_link); @@ -2635,11 +2622,6 @@ emacs_readlinkat (int fd, char const *filename) return Qnil; =20 val =3D build_unibyte_string (buf); - if (buf[0] =3D=3D '/' && strchr (buf, ':')) - { - AUTO_STRING (slash_colon, "/:"); - val =3D concat2 (slash_colon, val); - } if (buf !=3D readlink_buf) xfree (buf); val =3D DECODE_FILE (val); diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 9dc276b..0740996 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2538,13 +2538,16 @@ tramp--test-backtrace (should-error (make-symbolic-link tmp-name1 tmp-name2)) (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists) (should (file-symlink-p tmp-name2)) - ;; `tmp-name3' is a local file name. - (should-error (make-symbolic-link tmp-name1 tmp-name3))) + ;; `tmp-name3' is a local file name, so its target is not + ;; interpreted. + (make-symbolic-link tmp-name1 tmp-name3) + (should (equal tmp-name1 (file-symlink-p tmp-name3)))) =20 ;; Cleanup. (ignore-errors (delete-file tmp-name1) - (delete-file tmp-name2))) + (delete-file tmp-name2) + (delete-file tmp-name3))) =20 ;; Check `add-name-to-file'. (unwind-protect diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 2ef1b55..5103d2f 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -19,14 +19,13 @@ =20 (require 'ert) =20 -(defun try-char (char link) - (let ((target (string char))) - (make-symbolic-link target link) - (let* ((read-link (file-symlink-p link)) - (failure (unless (string-equal target read-link) - (list 'string-equal target read-link)))) - (delete-file link) - failure))) +(defun try-link (target link) + (make-symbolic-link target link) + (let* ((read-link (file-symlink-p link)) + (failure (unless (string-equal target read-link) + (list 'string-equal target read-link)))) + (delete-file link) + failure)) =20 (defun fileio-tests--symlink-failure () (let* ((dir (make-temp-file "fileio" t)) @@ -36,9 +35,9 @@ fileio-tests--symlink-failure (char 0)) (while (and (not failure) (< char 127)) (setq char (1+ char)) - (unless (=3D char ?~) - (setq failure (try-char char link)))) - failure) + (setq failure (try-link (string char) link))) + (or failure + (try-link "/:" link))) (delete-directory dir t)))) =20 (ert-deftest fileio-tests--odd-symlink-chars () --=20 2.7.4 --------------2AB0D6EE10F96C31D6D9FEDB-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 09:48:52 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 13:48:53 +0000 Received: from localhost ([127.0.0.1]:46196 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djQay-0005L5-P0 for submit@debbugs.gnu.org; Sun, 20 Aug 2017 09:48:52 -0400 Received: from mout.gmx.net ([212.227.15.19]:55624) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djQaw-0005Ks-R7 for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 09:48:51 -0400 Received: from detlef.gmx.de ([213.220.149.52]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MKHMk-1dl51D2eta-001gDj; Sun, 20 Aug 2017 15:48:33 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> Date: Sun, 20 Aug 2017 15:48:30 +0200 In-Reply-To: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> (Paul Eggert's message of "Sun, 20 Aug 2017 03:28:04 -0700") Message-ID: <87efs6fiz5.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:3+uaGdXFHV6Rl6JYcZZpViJGlGfvQj9/7P/CnBZVCG63xtki3rB XCZhZLttXs0lYCR8Rh3zBOTpnwVDHlPGt2IvGGEQzTsUgqIVMl/9+aHUFdXQ/r5V5MCiuxs Y1wxuPPAIW0HNiyIP32CwycZey2ohCdw7lvEVeRDxl41Euu06SyiS87sTjHj841vW2kjdrC MvLoXrxU9vIST4pf54V8g== X-UI-Out-Filterresults: notjunk:1;V01:K0:5NMQJe5jDho=:9BBbWJYF2cA5Jr/FXrki0M 2XJXEUBqWzXsDN39g1y/1Lrk8QpvWw7dgLVyjK8aGQxLheiLpnzMkqjUHUQWBRCyffff42NN3 iECC9274dZpYuip7ErmAM/0ti3KQgYaS8zOwyUoX0VNFjn4A4axAaO9E+ySY8EBJbL4QgR83g cjzb5acLebRSQ0+eXf9Yby+qEKmB8oA/xW4hN3NehM+3/gxlerOLPH7mbEKA3OFO8QScfxh+2 Oooo+0/W4RFNUmLt/T0JSAOl1XBQrUq/Ma0hfYZDWp02zNqKbjrm9IaRlMGO5LOldu4nZfUZ8 on6r2QNByaZKkaG0RncPoTW2H+h8Pr93rmdR0whjGTvxkYRuaxilHP9TieUY9iRxBujAs9jT5 ICpvi30WSNcwLKLNzZxmmyYavvryyjW08dD6RKi4zionKZXchkPf02fmTOtuJT0J4cJdjF8yW tPy4zW+E8Y9edb6/xcXA3QnRTEhT8He8D0eBaSNWI5eE8WFKdvKoTFBV0CJ7zOSFQBxgh9V8h 4WPm0Mj+6upBfntWcnEKbBO8uEcVZS5ETpnTwwkMl+A92AoPChpA4Vv3vLl4pCfj5D+GL4MkO WXAhTNlPEj+VBB7gS9KLhGFsbNS6t7RGKGigUdfM3SLnriREf8giNX6HiXYJbw6b8GwvTDJ9M lsqfzONaoWMH6njE7FYo/+68ZzeM/3BNqWk+nvgSjPtKW2BGol6h+yUGC27GWmUzzyuBSPGBo cifOPC/PIC11loXBDs7x+c1/IKCcqL+jI+WS0RTGLLWc6uX9ITfY1nb1qBb8vzMmSVDSTB/3g jIwq+2Zdi8RULpXWzP4I0DlDbegNM7DXLL0QMV16BSpRyuOHLs= X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: 28156 Cc: 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.5 (---) Paul Eggert writes: Hi Paul, > It strikes me that a similar change probably needs to be made to > Tramp, so that remote symlinks also can be arbitrary strings > too. However, that's outside my expertise so this patch affects only > local symlink contents. I'll have a look on this. Pls give me some days. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 10:37:21 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 14:37:21 +0000 Received: from localhost ([127.0.0.1]:46772 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djRLt-0006ZN-9k for submit@debbugs.gnu.org; Sun, 20 Aug 2017 10:37:21 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53704) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djRLr-0006Z9-Qq for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 10:37:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djRLl-0007cH-BX for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 10:37:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41599) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djRLg-0007aM-Gp; Sun, 20 Aug 2017 10:37:08 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4140 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1djRLf-0007b9-Rn; Sun, 20 Aug 2017 10:37:08 -0400 Date: Sun, 20 Aug 2017 17:37:00 +0300 Message-Id: <83pobqcnlf.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> (message from Paul Eggert on Sun, 20 Aug 2017 03:28:04 -0700) Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28156 Cc: michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Paul Eggert > Date: Sun, 20 Aug 2017 03:28:04 -0700 > Cc: Michael Albinus > > The attached patch fixes some Emacs behavior that disagrees with the > documentation. Although the user manual says that make-symbolic-link "does > not expand the argument TARGET", Emacs expands leading "~" in the target. Also, > file-symlink-p quietly munges symlink contents if they appear to be a Tramp file > name. This behavior makes it impossible to write Emacs code that deals with > arbitrary local symbolic links, and Emacs mishandles copying of some symlinks > for this reason. At the operating system level, symlink targets are merely > strings, and are not file names that are interpreted (any interpretation occurs > later, only when the symlinks are followed), and Emacs should be consistent with > that. Sorry, I'm probably missing something here, but doesn't Emacs behave here like Unix shell commands do? For example, I just did $ ln -s ~/bin/etags ttt and the following 'ls' command shows this: $ ls -l ttt lrwxrwxrwx 1 eliz eliz 22 Aug 20 10:27 ttt -> /home/e/eliz/bin/etags* AFAIU, this means the shell expanded "~" when it passed it to 'ln'. And Emacs tries to behave like the shell does in this case (and in other similar cases). Why is that wrong? Moreover, unless I again misunderstand something important, if make-symbolic-link would create a link like this: ttt -> ~/bin/etags (which is what your proposed change does, right?), then programs which follow the link will probably fail, because AFAIK most programs don't expand "~" (with the notable exception of the shell). What am I missing here? > +++ > +** 'file-attributes', 'file-symlink-p' and 'make-symbolic-link' no > +longer quietly mutate the target of a local symbolic link. In > +particular, 'file-attributes' and 'file-symlink-p' no longer prepend > +"/:" to some targets of local symbolic links, and 'make-symbolic-link' > +no longer expands '~' at the start of a link target. This change lets > +Emacs access and copy arbitrary local symbolic links. Regardless of the issue at hand, if the change is installed, this text should be clarified. As written, I find it very hard to understand what is the nature of the change, and how does it change the old behavior. For example, the reference to "some targets" could benefit from a couple of examples showing the old and the new behavior in each case. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 11:09:18 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 15:09:18 +0000 Received: from localhost ([127.0.0.1]:46819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djRqo-0007KO-7y for submit@debbugs.gnu.org; Sun, 20 Aug 2017 11:09:18 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:34800) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djRqn-0007KC-5Q for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 11:09:17 -0400 Received: by mail-oi0-f42.google.com with SMTP id j144so6290658oib.1 for <28156@debbugs.gnu.org>; Sun, 20 Aug 2017 08:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o5fy+sjEqqfv9JApk7nOHoqA/ceMbWjEYRIpXsGx4Wg=; b=cPXB/ay0T0+g3nk+xqnnZJPORLnrFv+uTPyb/C6eNVF/sYffh2uCzLcEhVNu3/L6I8 9atmkg6bGYKS6b+USLE9nTeSIBj3z3hj2S3iurD2YvFc4LrezuScNuB607nzt9ZmJimH JLggV8wABSEUOD/mS27qFR6483shSSiCZL6c3yNvJgJLLTeUm0y/u/OSwadz4PyN9bvE p1FdeuO7lp+i/07aIDYwbu1WZd/oyYGyWYWAIdbNtiDsLHPH0h+1WCpblGcdPnR7lD5C ZCbuL3SJmpzJUV3ieELAYabZuImcrt4AAc+Z1LaEHGWgALaHBOEjNJHRORjxk6VVf+0w X5jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o5fy+sjEqqfv9JApk7nOHoqA/ceMbWjEYRIpXsGx4Wg=; b=GY1SxvXPbIRNlfc/apCR/wSVEoL6uTJDZTJi1wSUKv9JyXvm1IMyDaJ7y46HRrBvpG aJaNse4o2GqXuGnf9ipyiwVhNJhK9Hcw9Y5vzhum24EqbrazvgqR3ciKqaapT1JIbsMg mOYucKJs6Kh2dSNmGy4Ue8cecvshRbtuvWOQVW/9T19b/h+BDv5vIqiI/TFR1H/ExS51 uMffUmOkPOquf0mmbllpJ/c6a4DsKC5epmdYOcjMhJFy7ad8NK4TSDL4TZqdzIOTZoY1 p88AqVVKDw1J6bXpfCaRLClT2A4jfT/m9qWWoFrA0m/n07BGw32ktapQfRXxYWtvENX1 DY8w== X-Gm-Message-State: AHYfb5jW0hLq+kf7dKdNFjZn0CNuXiyRikU7A2bQx6U6VWf5pIhwmNAf FEq8Zr4uHOswmxjxV3BD5P1F65jRUA== X-Received: by 10.202.194.139 with SMTP id s133mr18794331oif.222.1503241751476; Sun, 20 Aug 2017 08:09:11 -0700 (PDT) MIME-Version: 1.0 References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> In-Reply-To: <83pobqcnlf.fsf@gnu.org> From: Philipp Stephani Date: Sun, 20 Aug 2017 15:09:01 +0000 Message-ID: Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Eli Zaretskii , Paul Eggert Content-Type: multipart/alternative; boundary="001a113d32ac9bbdc3055730beaa" X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 28156 Cc: michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) --001a113d32ac9bbdc3055730beaa Content-Type: text/plain; charset="UTF-8" Eli Zaretskii schrieb am So., 20. Aug. 2017 um 16:38 Uhr: > > From: Paul Eggert > > Date: Sun, 20 Aug 2017 03:28:04 -0700 > > Cc: Michael Albinus > > > > The attached patch fixes some Emacs behavior that disagrees with the > > documentation. Although the user manual says that make-symbolic-link > "does > > not expand the argument TARGET", Emacs expands leading "~" in the > target. Also, > > file-symlink-p quietly munges symlink contents if they appear to be a > Tramp file > > name. This behavior makes it impossible to write Emacs code that deals > with > > arbitrary local symbolic links, and Emacs mishandles copying of some > symlinks > > for this reason. At the operating system level, symlink targets are > merely > > strings, and are not file names that are interpreted (any interpretation > occurs > > later, only when the symlinks are followed), and Emacs should be > consistent with > > that. > > Sorry, I'm probably missing something here, but doesn't Emacs behave > here like Unix shell commands do? For example, I just did > > $ ln -s ~/bin/etags ttt > > and the following 'ls' command shows this: > > $ ls -l ttt > lrwxrwxrwx 1 eliz eliz 22 Aug 20 10:27 ttt -> /home/e/eliz/bin/etags* > > AFAIU, this means the shell expanded "~" when it passed it to 'ln'. > And Emacs tries to behave like the shell does in this case (and in > other similar cases). Why is that wrong? > It makes it impossible to use '~' as a directory name. Higher-level interactive interfaces such as Shell and Dired can live with such a restriction, but library APIs need to be able to work with arbitrary inputs. > > Moreover, unless I again misunderstand something important, if > make-symbolic-link would create a link like this: > > ttt -> ~/bin/etags > > (which is what your proposed change does, right?), then programs which > follow the link will probably fail, because AFAIK most programs don't > expand "~" (with the notable exception of the shell). > > What am I missing here? Callers of `make-symbolic-link' will need to expand the target themselves. --001a113d32ac9bbdc3055730beaa Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= So., 20. Aug. 2017 um 16:38=C2=A0Uhr:
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Sun, 20 Aug 2017 03:28:04 -0700
> Cc: Michael Albinus <michael.albinus@gmx.de>
>
> The attached patch fixes some Emacs behavior that disagrees with the > documentation.=C2=A0 Although the user manual says that make-symbolic-= link "does
> not expand the argument TARGET", Emacs expands leading "~&qu= ot; in the target. Also,
> file-symlink-p quietly munges symlink contents if they appear to be a = Tramp file
> name. This behavior makes it impossible to write Emacs code that deals= with
> arbitrary local symbolic links, and Emacs mishandles copying of some s= ymlinks
> for this reason. At the operating system level, symlink targets are me= rely
> strings, and are not file names that are interpreted (any interpretati= on occurs
> later, only when the symlinks are followed), and Emacs should be consi= stent with
> that.

Sorry, I'm probably missing something here, but doesn't Emacs behav= e
here like Unix shell commands do?=C2=A0 For example, I just did

=C2=A0 $ ln -s ~/bin/etags ttt

and the following 'ls' command shows this:

=C2=A0 $ ls -l ttt
=C2=A0 lrwxrwxrwx 1 eliz eliz 22 Aug 20 10:27 ttt -> /home/e/eliz/bin/et= ags*

AFAIU, this means the shell expanded "~" when it passed it to = 9;ln'.
And Emacs tries to behave like the shell does in this case (and in
other similar cases).=C2=A0 Why is that wrong?

It makes it impossible to use '~' as a directory name. High= er-level interactive interfaces such as Shell and Dired can live with such = a restriction, but library APIs need to be able to work with arbitrary inpu= ts.
=C2=A0

Moreover, unless I again misunderstand something important, if
make-symbolic-link would create a link like this:

=C2=A0 ttt -> ~/bin/etags

(which is what your proposed change does, right?), then programs which
follow the link will probably fail, because AFAIK most programs don't expand "~" (with the notable exception of the shell).

What am I missing here?

Callers of `make-sy= mbolic-link' will need to expand the target themselves.=C2=A0
--001a113d32ac9bbdc3055730beaa-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 11:39:02 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 15:39:02 +0000 Received: from localhost ([127.0.0.1]:46830 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djSJa-0007zS-1t for submit@debbugs.gnu.org; Sun, 20 Aug 2017 11:39:02 -0400 Received: from eggs.gnu.org ([208.118.235.92]:32771) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djSJY-0007yw-1U for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 11:39:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djSJM-0005oU-D7 for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 11:38:51 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:41942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djSJM-0005oO-A0; Sun, 20 Aug 2017 11:38:48 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4229 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1djSJL-0005ay-Lb; Sun, 20 Aug 2017 11:38:48 -0400 Date: Sun, 20 Aug 2017 18:38:40 +0300 Message-Id: <83h8x2ckqn.fsf@gnu.org> From: Eli Zaretskii To: Philipp Stephani In-reply-to: (message from Philipp Stephani on Sun, 20 Aug 2017 15:09:01 +0000) Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28156 Cc: eggert@cs.ucla.edu, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Philipp Stephani > Date: Sun, 20 Aug 2017 15:09:01 +0000 > Cc: michael.albinus@gmx.de, 28156@debbugs.gnu.org > > It makes it impossible to use '~' as a directory name. Higher-level interactive interfaces such as Shell and > Dired can live with such a restriction, but library APIs need to be able to work with arbitrary inputs. We have quoting for these cases. > Callers of `make-symbolic-link' will need to expand the target themselves. make-symbolic-link is an interactive command, not just a function. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 13:54:59 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 17:54:59 +0000 Received: from localhost ([127.0.0.1]:46849 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djUR8-0002cF-LU for submit@debbugs.gnu.org; Sun, 20 Aug 2017 13:54:59 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:43468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djUR6-0002c2-Hc for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 13:54:57 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 745B41608B2; Sun, 20 Aug 2017 10:54:50 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 05LGzG7O2ETp; Sun, 20 Aug 2017 10:54:49 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 41AC7160888; Sun, 20 Aug 2017 10:54:49 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BEem7sLyfDO4; Sun, 20 Aug 2017 10:54:49 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1454E160882; Sun, 20 Aug 2017 10:54:49 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Eli Zaretskii , Philipp Stephani References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sun, 20 Aug 2017 10:54:45 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83h8x2ckqn.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------5539653B2399E54E7B1DA5D5" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------5539653B2399E54E7B1DA5D5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Eli Zaretskii wrote: > We have quoting for these cases. Quoting does not work for these cases. If I try to rename a symlink to th= e=20 literal string '~eggert' on my machine, Emacs will misbehave as described= and=20 there is no way to quote the string naming the symlink to fix this. > doesn't Emacs behave here like Unix shell commands do? They differ in many ways. Two examples. First, the Unix shell command 'ln= -s=20 ~/$$ def' expands both the "~" and the "$$", whereas (make-symbolic-link = "~/$$"=20 "def") expands only the "~". Second, the Unix shell command "ln -s def" c= reates=20 a symlink to itself, whereas (make-symbolic-link "def") is an error. Brie= fly,=20 the Unix shell commands are higher-level than the Emacs primitives. The main points here are (1) Emacs functions should let users create and=20 manipulate whatever symlinks they want to, and (2) the documentation has = long=20 said that symlinks are not expanded. > If make-symbolic-link would create a link like this: >=20 > ttt -> ~/bin/etags >=20 > (which is what your proposed change does, right?), then programs which > follow the link will probably fail Yes, they will fail unless there is a directory named '~'. That is the in= tent.=20 If I want to create a symlink to my home directory, I can use expand-file= -name=20 on the link target, before calling make-symbolic-link. > this text should be clarified. Sure, that's easy. Revised patch attached. --------------5539653B2399E54E7B1DA5D5 Content-Type: text/x-patch; name="0001-Do-not-munge-contents-of-local-symbolic-links.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Do-not-munge-contents-of-local-symbolic-links.patch" =46rom 6a3f716feac756a6e80ba4c571155377bd1cba28 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 20 Aug 2017 03:13:52 -0700 Subject: [PATCH] Do not munge contents of local symbolic links This lets Emacs deal with arbitrary local symlinks without mishandling their contents. For example, (progn (shell-command "ln -fs '~' 'x'") (rename-file "x" "/tmp/x")) now consistently creates a symbolic link from '/tmp/x' to '~'. Formerly, it did that only if the working directory was on the same filesystem as /tmp; otherwise, it expanded the '~' to the user's home directory. * etc/NEWS: Document the change. * src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the target, and look for special constructs only in the new link name, not the target. (emacs_readlinkat): Do not preprend "/:" to the link target if it starts with "/" and contains ":" before NUL. * test/lisp/net/tramp-tests.el (tramp-test21-file-links): Adjust to new behavior. * test/src/fileio-tests.el (try-link): Rename from try-char, and accept a string instead of a char. All uses changed. (fileio-tests--symlink-failure): Also test leading ~, and "/:", to test the new behavior. --- etc/NEWS | 15 +++++++++++++++ src/fileio.c | 18 ------------------ test/lisp/net/tramp-tests.el | 9 ++++++--- test/src/fileio-tests.el | 21 ++++++++++----------- 4 files changed, 31 insertions(+), 32 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 7774d75..3bafb87 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1204,6 +1204,21 @@ instead of to utf-8. Before this change, Emacs wo= uld sometimes mishandle file names containing these control characters. =20 +++ +** 'file-attributes', 'file-symlink-p' and 'make-symbolic-link' no +longer quietly mutate the target of a local symbolic link, so that +Emacs can access and copy them reliably regardless of their contents. +Two changes are involved. First, 'file-attributes' and +'file-symlink-p' no longer prepend "/:" to symbolic links whose +targets begin with "/" and contain ":". For example, if a symbolic +link "x" has a target "/y:z", (file-symlink-p "x") now returns "/y:z" +rather than "/:/y:z". Second, 'make-symbolic-link' no longer expands +"~" at the start of a link target before creating the link. For +example, (make-symbolic-link "~y" "x") now creates a symbolic link +with target being the string "~y" and not the home directory of the +user y. To create a symbolic link to y's home directory, use +(make-symbolic-link (expand-file-name "~y") "x"). + ++++ ** Module functions are now implemented slightly differently; in particular, the function 'internal--module-call' has been removed. Code that depends on undocumented internals of the module system might diff --git a/src/fileio.c b/src/fileio.c index f954ac1..ce243c3 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2423,21 +2423,8 @@ This happens for interactive use with M-x. */) Lisp_Object encoded_target, encoded_linkname; =20 CHECK_STRING (target); - /* If the link target has a ~, we must expand it to get - a truly valid file name. Otherwise, do not expand; - we want to permit links to relative file names. */ - if (SREF (target, 0) =3D=3D '~') - target =3D Fexpand_file_name (target, Qnil); - linkname =3D expand_cp_target (target, linkname); =20 - /* If the file name has special constructs in it, - call the corresponding file handler. */ - handler =3D Ffind_file_name_handler (target, Qmake_symbolic_link); - if (!NILP (handler)) - return call4 (handler, Qmake_symbolic_link, target, - linkname, ok_if_already_exists); - /* If the new link name has special constructs in it, call the corresponding file handler. */ handler =3D Ffind_file_name_handler (linkname, Qmake_symbolic_link); @@ -2635,11 +2622,6 @@ emacs_readlinkat (int fd, char const *filename) return Qnil; =20 val =3D build_unibyte_string (buf); - if (buf[0] =3D=3D '/' && strchr (buf, ':')) - { - AUTO_STRING (slash_colon, "/:"); - val =3D concat2 (slash_colon, val); - } if (buf !=3D readlink_buf) xfree (buf); val =3D DECODE_FILE (val); diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 9dc276b..0740996 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2538,13 +2538,16 @@ tramp--test-backtrace (should-error (make-symbolic-link tmp-name1 tmp-name2)) (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists) (should (file-symlink-p tmp-name2)) - ;; `tmp-name3' is a local file name. - (should-error (make-symbolic-link tmp-name1 tmp-name3))) + ;; `tmp-name3' is a local file name, so its target is not + ;; interpreted. + (make-symbolic-link tmp-name1 tmp-name3) + (should (equal tmp-name1 (file-symlink-p tmp-name3)))) =20 ;; Cleanup. (ignore-errors (delete-file tmp-name1) - (delete-file tmp-name2))) + (delete-file tmp-name2) + (delete-file tmp-name3))) =20 ;; Check `add-name-to-file'. (unwind-protect diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 2ef1b55..5103d2f 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -19,14 +19,13 @@ =20 (require 'ert) =20 -(defun try-char (char link) - (let ((target (string char))) - (make-symbolic-link target link) - (let* ((read-link (file-symlink-p link)) - (failure (unless (string-equal target read-link) - (list 'string-equal target read-link)))) - (delete-file link) - failure))) +(defun try-link (target link) + (make-symbolic-link target link) + (let* ((read-link (file-symlink-p link)) + (failure (unless (string-equal target read-link) + (list 'string-equal target read-link)))) + (delete-file link) + failure)) =20 (defun fileio-tests--symlink-failure () (let* ((dir (make-temp-file "fileio" t)) @@ -36,9 +35,9 @@ fileio-tests--symlink-failure (char 0)) (while (and (not failure) (< char 127)) (setq char (1+ char)) - (unless (=3D char ?~) - (setq failure (try-char char link)))) - failure) + (setq failure (try-link (string char) link))) + (or failure + (try-link "/:" link))) (delete-directory dir t)))) =20 (ert-deftest fileio-tests--odd-symlink-chars () --=20 2.7.4 --------------5539653B2399E54E7B1DA5D5-- From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 14:28:38 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 18:28:38 +0000 Received: from localhost ([127.0.0.1]:46883 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djUxi-0003PE-5D for submit@debbugs.gnu.org; Sun, 20 Aug 2017 14:28:38 -0400 Received: from mout.gmx.net ([212.227.17.21]:61454) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djUxf-0003Oz-TC for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 14:28:36 -0400 Received: from detlef.gmx.de ([213.220.149.52]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MfBsk-1duyL549UI-00OlD1; Sun, 20 Aug 2017 20:28:18 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> Date: Sun, 20 Aug 2017 20:28:15 +0200 In-Reply-To: (Paul Eggert's message of "Sun, 20 Aug 2017 10:54:45 -0700") Message-ID: <87y3qexfeo.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:xW7NHVV/5zv6ghaFwTVl9k4MxZaxUUWSbaqdGCTyOfw8XzjhQsB 9iDZaGOP9UzhCYd/xdz0doVJ4gmG7ZkIvdiyBvqs/f+Bxr/d1IAxuQWU32Zz/4XHJTH3bd9 CUZDxSR5Byq6MjaqGlJtW7N4KcEnKH2TjcKd9jb1Z7lY1lRtS0afu8K5sdguvvDzc5UYtSj Ps0UL3ei488JgJ46pKcLw== X-UI-Out-Filterresults: notjunk:1;V01:K0:rLSwilHWSaU=:eP1RbEmocQ0+hu7wRknIOl PvWgOWMmcuukHkrqKc/7XxCotwIcLQkCOTIvWtuqThm+DVkY7L4ikTBH5XyGtyp4rTE65De86 P3zrfloKBDqnWzqZ21QAgl/HAHkG1S0zqffxqE2NWDxJRI8zuha4MsnbUEsg8r34Hkqlj2009 cH1/Db5TTPFqee3wBYCWTKxlwqh7wEZFPlDWYhnWfyN42APX/BdWswGc8AN1e1J+12hwZEhWz +lZusYq50OkMUUQwaJBNOInLGkPtPGFJzqgHlVFTbV3BtLCVDKp5NsCf22eyMI6HBqsD2ofhb Dik9kBpyTsZK1P0dPp1tzQmbAryF++VZ0J+6ZoCei3+uaTD0WRqxWUs2bofWx+6Xj2y5CFrsA DZZiQyoThGeRlgZfsru5YK3dE0rYTfXlsCZ/RuG0M2sNhVs3GvZBS6/Bg6xr0XS8aAOR/eRTB DOUfMF6ds8/eSdwzduKn81d7jc9Su6fvhvDOS6sD5zJ4GsuZVZjBNmxuXobthpsxY6pem+FmJ A32AfYRYdu7TaEyrx/i/3uCi7c8QCMfYGO7qG9E6Aqq6SJ2Dfc1+rBG9zJq14Ejoqt/8bUPTD rqKBXPl/ttaze+EIWEY3QvjXHp4xjzrjIk7n0J6XE60XJV4OhpfU1ZruH7UebqNNuxcyTj39u ipgAcXLTTeBtjRiyvCCgacDlKmAiUIFFDSUvp3hInzqJnVe3Zn2IHwDrtMNZ03EEcEmFlzZb0 BVwe3vLGjRlu77G+6pG17VN69N9glS5GX0pl0GExeB7iAO1LPhLYx9IFs/dnNDBPSswM/IoPM kWQGKMgdH64RlF91o9nnm/FF+8U+j+PUESfIoX5RCIWqJelYK0= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , Philipp Stephani , 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Paul Eggert writes: >> We have quoting for these cases. > > Quoting does not work for these cases. If I try to rename a symlink to > the literal string '~eggert' on my machine, Emacs will misbehave as > described and there is no way to quote the string naming the symlink > to fix this. (make-symbolic-link "~/.emacs" "/:/tmp/~eggert") # ls -l /tmp [...] lrwxrwxrwx 1 albinus albinus 20 Aug 20 20:24 ~eggert -> /home/albinus/.emacs (rename-file "/:/tmp/~eggert" "/:/tmp/~albinus") # ls -l /tmp [...] lrwxrwxrwx 1 albinus albinus 20 Aug 20 20:24 ~albinus -> /home/albinus/.emacs Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 14:54:04 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 18:54:04 +0000 Received: from localhost ([127.0.0.1]:46894 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djVMJ-0003ye-Rc for submit@debbugs.gnu.org; Sun, 20 Aug 2017 14:54:04 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:46864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djVMI-0003yB-Bb for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 14:54:02 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AA8EB160883; Sun, 20 Aug 2017 11:53:56 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id DLT9r2QcbqRK; Sun, 20 Aug 2017 11:53:56 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EE59C16088D; Sun, 20 Aug 2017 11:53:55 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KsH_xH8Z1ZQ2; Sun, 20 Aug 2017 11:53:55 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C972F160883; Sun, 20 Aug 2017 11:53:55 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Michael Albinus References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> Date: Sun, 20 Aug 2017 11:53:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87y3qexfeo.fsf@detlef> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , Philipp Stephani , 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Michael Albinus wrote: >>> We have quoting for these cases. >> Quoting does not work for these cases. If I try to rename a symlink to >> the literal string '~eggert' on my machine, Emacs will misbehave as >> described and there is no way to quote the string naming the symlink >> to fix this. > (make-symbolic-link "~/.emacs" "/:/tmp/~eggert") ... That's not the problem I was referring to. Sorry, I should have given mor= e=20 detail. By "misbehave as described" I was referring to an earlier-mention= ed=20 scenario where rename-file copies because the source and destination are = on=20 different filesystems. For example, suppose the current directory is on a= =20 different filesystem from /tmp, and I execute the following in my *scratc= h* buffer: (shell-command "ln -s '~' symlink") 0 (file-symlink-p "symlink") "~" (rename-file "symlink" "/tmp/symlink") nil (file-symlink-p "/tmp/symlink") "/home/eggert" Here, rename-file quietly expands the symlink contents, which is a bug. A= s far=20 as I can see, one cannot work around the bug by using Tramp quoting; for=20 example, (rename-file "/:symlink" "/:/tmp/symlink") does the same thing t= hat=20 (rename-file "symlink" "/tmp/symlink") does. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 15:15:35 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 19:15:35 +0000 Received: from localhost ([127.0.0.1]:46914 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djVh8-0004VE-W5 for submit@debbugs.gnu.org; Sun, 20 Aug 2017 15:15:35 -0400 Received: from mout.gmx.net ([212.227.17.20]:53317) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djVh7-0004V2-Gs for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 15:15:33 -0400 Received: from detlef.gmx.de ([213.220.149.52]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0M1WHV-1dPDgb0GAT-00tRlb; Sun, 20 Aug 2017 21:15:16 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> Date: Sun, 20 Aug 2017 21:15:14 +0200 In-Reply-To: <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> (Paul Eggert's message of "Sun, 20 Aug 2017 11:53:55 -0700") Message-ID: <871so62gql.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:eZ0+yoa1/CUvCBxM/mzeuBQDHe/QcbYhvadaNPODH3gH23Y4Q6f IGIJRGInFXituqapGNb2iISfM5Fq0I4uTnQEZwp1nUYm15/Ic782toEGca55+L5zytDK7wm l3uplVRjKDTNFVNo4m/GoTMuiXPSdpBzMmxKQRJ5dn028yeqVaEWn7pl3dSl65TY3ETXToz N4/JKrrYQ3wQvV7uI8HRQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:g/CtIf/4f9k=:FJQpNEjqAiKcHk1Tm0FblK MkPNNDA6gLAjPW9eLxYt80EWmPST5wpvqKbnMnhUr8hxrGbSKDB20wRlLAvxxOoC9nwmNwXrH mBGeRGmx3jdknVIdGBTtZWNcBFyu8QjWad4/IizjNiOcpxyJrH8Xkr/Ejz3Jmc+wKrHIkD0/W ISJCMkDJAOvsahVAOOk8EEyCgq3xHrdgR+X0Zo0tnrYmF/YCvJhakKZwT4zk0ZzSvaejtGOKA AaMmiIgKcK+jtUkw20fVb3XZB6kHfiaWTwdiODOQbVP4HZ+79SCE5bt2LzlmBpEdYHT8Nq9iS +D8Mhe7AhR1MLrIonqVTLDWyjR5DjXYKICkUGN12aEwxwKFoHFNYe8QXKRTVaO6Nc6bFtvNGu EnfxNYsRxdkEu4c7tWbbm2I/jq2pBGeZsfW3UwEVfeBjhyq3oDetqGhceeDs1dsgeLG735ttp 4GgccIsqon9Bgtd2DvvNqL1UptCLI5AjDtP9+GR/7WR6fkTs0Nv/HqbpKALwhDEm/Cd34cvSr vCgIF14jKDH6NymBxvHh+80PsEXtUDJ9HILaL0qxTu2bMQPPBUzcOOYh3rqFGZ7lGXNPqGulk jCAqfDR6XDq0z94Rzy9P/h4nc8yqNP2tHKdnAhDc9i9ynHXbTgEABU2fQi1H5JQoHDS11Q2z6 Wpv0t0ubMMlsY+CvCudyHi9ojaRRlsg826o9YuxwRfb0kATfsLGJBG9JL9/FatntkUsyewL1i HLoD+Skd0K/eaieb1VJoFmtG0YcQlKrGuB4oVDotviG8hbCTxgV8lF9DEzW31tX0KzMTJQbKF hQ41bbsm58Z31WcBYyMNu/db0Jjz9Rn4CsFV6JNbSMmL8qVTPU= X-Spam-Score: -0.2 (/) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , Philipp Stephani , 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.2 (/) Paul Eggert writes: Hi Paul, > Here, rename-file quietly expands the symlink contents, which is a > bug. As far as I can see, one cannot work around the bug by using > Tramp quoting; for example, (rename-file "/:symlink" "/:/tmp/symlink") > does the same thing that (rename-file "symlink" "/tmp/symlink") does. Just to understand what you are speaking about: what do you mean with "Tramp quoting"? A file name starting with "/:" has nothing to do with Tramp. (For the rest of your email I need to run some tests) Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 15:16:58 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 19:16:58 +0000 Received: from localhost ([127.0.0.1]:46918 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djViU-0004Xb-9W for submit@debbugs.gnu.org; Sun, 20 Aug 2017 15:16:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37669) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djViR-0004XN-UE for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 15:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djViJ-0007Au-Gk for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 15:16:50 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djViJ-0007Ao-D3; Sun, 20 Aug 2017 15:16:47 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4392 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1djViF-0002DE-Nm; Sun, 20 Aug 2017 15:16:47 -0400 Date: Sun, 20 Aug 2017 22:16:04 +0300 Message-Id: <83bmnacaob.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: (message from Paul Eggert on Sun, 20 Aug 2017 10:54:45 -0700) Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: michael.albinus@gmx.de, 28156@debbugs.gnu.org > From: Paul Eggert > Date: Sun, 20 Aug 2017 10:54:45 -0700 > > > We have quoting for these cases. > > Quoting does not work for these cases. If I try to rename a symlink to the > literal string '~eggert' on my machine, Emacs will misbehave as described and > there is no way to quote the string naming the symlink to fix this. That is but one use case of many. In other cases, quoting does work. > > doesn't Emacs behave here like Unix shell commands do? > > They differ in many ways. Two examples. First, the Unix shell command 'ln -s > ~/$$ def' expands both the "~" and the "$$", whereas (make-symbolic-link "~/$$" > "def") expands only the "~". Second, the Unix shell command "ln -s def" creates > a symlink to itself, whereas (make-symbolic-link "def") is an error. Briefly, > the Unix shell commands are higher-level than the Emacs primitives. I never said that Emacs does everything the shell does, and does it exactly like the shell. I was only talking about "~" expansion, so let's not muddy the waters by adding more magic characters and expansions into what is already a tricky issue. > The main points here are (1) Emacs functions should let users create and > manipulate whatever symlinks they want to, and (2) the documentation has long > said that symlinks are not expanded. I agree. But I think your proposed changes will disallow some of the users' capabilities to do what you want. What's more, they seem to sacrifice a very common interactive use case on behalf of a much more rare and obscure one. I'm talking about a user typing this: M-x make-symbolic-link RET ~/foo/bar RET /toto/quux RET AFAIU, with your changes the "~" in the first file name will not be expanded. If I'm right, then you will disallow using "~" as the short for the home directory in this case, which IMO is unacceptable, as Emacs allows this in any other interactive command that accepts file names. At the very least, we should preserve the current ability of the user to specify "~" shorthands in interactive invocations of make-symbolic-link. If you want to allow users to specify a literal "~" in this scenario, I agree, but it seems like we already allow that; see Micheal's example. > > If make-symbolic-link would create a link like this: > > > > ttt -> ~/bin/etags > > > > (which is what your proposed change does, right?), then programs which > > follow the link will probably fail > > Yes, they will fail unless there is a directory named '~'. That is the intent. > If I want to create a symlink to my home directory, I can use expand-file-name > on the link target, before calling make-symbolic-link. We cannot force users call expand-file-name in interactive use of these commands. It's simply unacceptable. I don't even know how users could do that in practice -- do you expect them to type TAB or something? How can this work? From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 15:22:34 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 19:22:34 +0000 Received: from localhost ([127.0.0.1]:46922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djVnu-0004fZ-2C for submit@debbugs.gnu.org; Sun, 20 Aug 2017 15:22:34 -0400 Received: from eggs.gnu.org ([208.118.235.92]:38282) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djVns-0004fO-Vd for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 15:22:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djVnk-0000vc-Mh for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 15:22:27 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djVnk-0000vY-Jb; Sun, 20 Aug 2017 15:22:24 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4407 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1djVni-0002Ug-0R; Sun, 20 Aug 2017 15:22:24 -0400 Date: Sun, 20 Aug 2017 22:21:43 +0300 Message-Id: <83a82ucaew.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> (message from Paul Eggert on Sun, 20 Aug 2017 11:53:55 -0700) Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: Eli Zaretskii , Philipp Stephani , > 28156@debbugs.gnu.org > From: Paul Eggert > Date: Sun, 20 Aug 2017 11:53:55 -0700 > > (shell-command "ln -s '~' symlink") > 0 > (file-symlink-p "symlink") > "~" > (rename-file "symlink" "/tmp/symlink") > nil > (file-symlink-p "/tmp/symlink") > "/home/eggert" If this is the problem, then let's solve it without affecting make-symbolic-link. The problem you show is in file-symlink-p and/or in rename-file. Let's solve it there, and let's solve it without affecting the interactive callers of those functions. > Here, rename-file quietly expands the symlink contents, which is a bug. As far > as I can see, one cannot work around the bug by using Tramp quoting; for > example, (rename-file "/:symlink" "/:/tmp/symlink") does the same thing that > (rename-file "symlink" "/tmp/symlink") does. But AFAIU, file-symlink-p can return a quoted name if its argument is quoted. Doesn't this allow to solve the problem? From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 17:31:49 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 21:31:49 +0000 Received: from localhost ([127.0.0.1]:47024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djXoz-0002uk-Eb for submit@debbugs.gnu.org; Sun, 20 Aug 2017 17:31:49 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55596) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djXox-0002uV-MF for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 17:31:48 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 971C716088D; Sun, 20 Aug 2017 14:31:41 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ywmpUZ2gYYoY; Sun, 20 Aug 2017 14:31:40 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id DF3B416088A; Sun, 20 Aug 2017 14:31:40 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wbx4K0TC0uGU; Sun, 20 Aug 2017 14:31:40 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id B96DC160882; Sun, 20 Aug 2017 14:31:40 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Eli Zaretskii References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> <83a82ucaew.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sun, 20 Aug 2017 14:31:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83a82ucaew.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Eli Zaretskii wrote: >> (shell-command "ln -s '~' symlink") >> 0 >> (file-symlink-p "symlink") >> "~" >> (rename-file "symlink" "/tmp/symlink") >> nil >> (file-symlink-p "/tmp/symlink") >> "/home/eggert" > > If this is the problem, It's just one instance of the problem. > then let's solve it without affecting > make-symbolic-link. This instance of the problem occurs because rename-file calls make-symbolic-link, and make-symbolic-link silently alters the link target. The real problem here is with make-symbolic-link: the rename-file bug is just a symptom. >> Here, rename-file quietly expands the symlink contents, which is a bug. As far >> as I can see, one cannot work around the bug by using Tramp quoting; for >> example, (rename-file "/:symlink" "/:/tmp/symlink") does the same thing that >> (rename-file "symlink" "/tmp/symlink") does. > > But AFAIU, file-symlink-p can return a quoted name if its argument is > quoted. I don't know what you mean by "quoted". file-symlink-returns a string, and the string is supposed to be the contents of the symlink. file-symlink-p is working correctly here. It's make-symbolic-link (called from rename-file) that is screwing up. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 17:47:13 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 21:47:13 +0000 Received: from localhost ([127.0.0.1]:47029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djY3s-0003Fs-Pr for submit@debbugs.gnu.org; Sun, 20 Aug 2017 17:47:12 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56262) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djY3q-0003Fd-Q1 for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 17:47:11 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 78FE9160882; Sun, 20 Aug 2017 14:47:04 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id E5as94rRLeIy; Sun, 20 Aug 2017 14:47:02 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id E4F431608B1; Sun, 20 Aug 2017 14:47:02 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id e-Fm2ayAPmBq; Sun, 20 Aug 2017 14:47:02 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id C00CB160882; Sun, 20 Aug 2017 14:47:02 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Michael Albinus References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> <871so62gql.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <9d6b82a7-034c-da82-5510-e9cdef3068c4@cs.ucla.edu> Date: Sun, 20 Aug 2017 14:47:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <871so62gql.fsf@detlef> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , Philipp Stephani , 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Michael Albinus wrote: > Just to understand what you are speaking about: what do you mean with > "Tramp quoting"? A file name starting with "/:" has nothing to do with > Tramp. Sorry, I'm afraid I don't understand Tramp at all but I don't think it matters. By "Tramp quoting" I was referring to the technique you used in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28156#23 to create a symlink whose name starts with "~", by prefixing the name with "/:/tmp/". I don't know why the "/:" is there and it doesn't really matter, since the bug in question is not with the name of the symlink, it is with the contents of the symlink. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 18:18:05 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 22:18:05 +0000 Received: from localhost ([127.0.0.1]:47043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djYXk-0005mS-TM for submit@debbugs.gnu.org; Sun, 20 Aug 2017 18:18:05 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:37795) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djYXi-0005lx-KV for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 18:18:02 -0400 Received: by mail-it0-f65.google.com with SMTP id 77so8952297itj.4 for <28156@debbugs.gnu.org>; Sun, 20 Aug 2017 15:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=b7XvT7hNIxSO4jER7xVRfadyWNRqjFmVtK3xhyGpJFQ=; b=MAbIFjzENRMLWRrXfiuMKtqJkH6BaVe+d0EY/avLcBItzLu/Ldm5gjconRcXfsgspR QKtRY5Vfud83Et0JDthtd0Rjwsf5/X5CwiYJ4urRTbgENnmE3UvWhK9awzdetZnxGxlU cCxwctDRF6TvPko28LRfN0Gqi6uboKTOoFTivTttOp73qnZvk+yx/h0d4Q93RR1ToE0z UfwMMCtIL1Ba1gDm9pWhJ6NDTKvWCUPsdA//B+KqWst22cPes/SMn62LgBSl7xOJMs/b 1r+N7qep1UGBTbAWrZT8H/uj3iwIA5GE8MNiexD58nXox38aMdEGoWd5aA51NZK3I6by zwxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=b7XvT7hNIxSO4jER7xVRfadyWNRqjFmVtK3xhyGpJFQ=; b=M9hHcTxMbYQLW/z2ADbapTOj6vLJGToU6ViCUk19CJ0Fj4ZQzFPNe0uWQ4Px8K0GLh Rdim19mOKqFO5PF2+6xwHpKkmdyVhjWzDr4wUlt2iUmFNs8gcAyYG0PEC26UelEvYxUw GK2mBa0qJea467v201kAkjsBw/CnVYqOZFO1sIEwW00vfwLJkNIV4xkRDlpHFmFor3Dw rNYD2sG90q+tfDV9qPVvC0OKbQLpbv0P8034yDmRx1WX4cRj+AKXTaVlNH9aahZioGSk 2ufau+dgkeGahtUTXjj9J/6NT0Guq/CYWTWrMco/DQse17yXo5YdOGvHcX6SuF4LO9oU wKvQ== X-Gm-Message-State: AHYfb5guwQkuwReq8wO5GtmgHSnZZpBkkLtmsqx3goCh46DapP4rGpJN FOGVEJBWGbGo6g== X-Received: by 10.36.170.79 with SMTP id y15mr4244485iti.12.1503267477013; Sun, 20 Aug 2017 15:17:57 -0700 (PDT) Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id 79sm3249967itu.31.2017.08.20.15.17.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Aug 2017 15:17:56 -0700 (PDT) From: npostavs@users.sourceforge.net To: Eli Zaretskii Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> Date: Sun, 20 Aug 2017 18:19:33 -0400 In-Reply-To: <83h8x2ckqn.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 20 Aug 2017 18:38:40 +0300") Message-ID: <87mv6tanm2.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 28156 Cc: Philipp Stephani , eggert@cs.ucla.edu, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) Eli Zaretskii writes: >> Callers of `make-symbolic-link' will need to expand the target themselves. > > make-symbolic-link is an interactive command, not just a function. Can we not just do the expansion in the interactive form then? From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 19:00:13 2017 Received: (at 28156) by debbugs.gnu.org; 20 Aug 2017 23:00:13 +0000 Received: from localhost ([127.0.0.1]:47053 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djZCX-0006io-Ha for submit@debbugs.gnu.org; Sun, 20 Aug 2017 19:00:13 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:60026) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djZCW-0006ib-CI for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 19:00:12 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BBFC31608A6; Sun, 20 Aug 2017 16:00:06 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 3M83n0FCcd8n; Sun, 20 Aug 2017 16:00:06 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 167491608A4; Sun, 20 Aug 2017 16:00:06 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id KDNNkAZoVS_3; Sun, 20 Aug 2017 16:00:06 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E3629160890; Sun, 20 Aug 2017 16:00:05 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: npostavs@users.sourceforge.net, Eli Zaretskii References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87mv6tanm2.fsf@users.sourceforge.net> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sun, 20 Aug 2017 16:00:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87mv6tanm2.fsf@users.sourceforge.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: Philipp Stephani , michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) npostavs@users.sourceforge.net wrote: > Can we not just do the expansion in the interactive form then? Yes, that makes sense. I'll modify the patch along those lines. From debbugs-submit-bounces@debbugs.gnu.org Sun Aug 20 22:34:31 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 02:34:31 +0000 Received: from localhost ([127.0.0.1]:47112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djcXv-00032d-EI for submit@debbugs.gnu.org; Sun, 20 Aug 2017 22:34:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53042) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djcXt-00032Q-Im for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 22:34:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djcXl-0001rY-BM for 28156@debbugs.gnu.org; Sun, 20 Aug 2017 22:34:24 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djcXl-0001rS-83; Sun, 20 Aug 2017 22:34:21 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4654 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1djcXk-0003rI-Mt; Sun, 20 Aug 2017 22:34:21 -0400 Date: Mon, 21 Aug 2017 05:34:14 +0300 Message-Id: <834lt1d4yh.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: (message from Paul Eggert on Sun, 20 Aug 2017 14:31:40 -0700) Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> <83a82ucaew.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: michael.albinus@gmx.de, p.stephani2@gmail.com, 28156@debbugs.gnu.org > From: Paul Eggert > Date: Sun, 20 Aug 2017 14:31:40 -0700 > > This instance of the problem occurs because rename-file calls > make-symbolic-link, and make-symbolic-link silently alters the link target. The > real problem here is with make-symbolic-link: the rename-file bug is just a symptom. Then you want a way of invoking make-symbolic-link non-interactively that doesn't expand "~", AFAIU. No need to affect its interactive invocation. > >> Here, rename-file quietly expands the symlink contents, which is a bug. As far > >> as I can see, one cannot work around the bug by using Tramp quoting; for > >> example, (rename-file "/:symlink" "/:/tmp/symlink") does the same thing that > >> (rename-file "symlink" "/tmp/symlink") does. > > > > But AFAIU, file-symlink-p can return a quoted name if its argument is > > quoted. > > I don't know what you mean by "quoted". I mean this: (file-symlink-p "/:/tmp/symlink") There's special code in file-symlink-p to support this and return a quoted name of the symlink target. For some reason, you wanted to remove that code. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 03:37:15 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 07:37:15 +0000 Received: from localhost ([127.0.0.1]:47256 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djhGt-0001dm-Gd for submit@debbugs.gnu.org; Mon, 21 Aug 2017 03:37:15 -0400 Received: from mout.gmx.net ([212.227.15.18]:61755) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djhGr-0001dY-KS for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 03:37:14 -0400 Received: from detlef.gmx.de ([213.220.149.52]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MUYnD-1e9vOe1Tf9-00RLrC; Mon, 21 Aug 2017 09:36:55 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> <871so62gql.fsf@detlef> <9d6b82a7-034c-da82-5510-e9cdef3068c4@cs.ucla.edu> Date: Mon, 21 Aug 2017 09:36:50 +0200 In-Reply-To: <9d6b82a7-034c-da82-5510-e9cdef3068c4@cs.ucla.edu> (Paul Eggert's message of "Sun, 20 Aug 2017 14:47:02 -0700") Message-ID: <877exxpe25.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:Vuw1gGCAlsR/RGJFayM6xCR9Tb953K9mbtxxotrS+CACcC75ooP TVMXSt5ibQAcHGPyxcz1o8S96o1YXFCUpU/VSbkuy1LQl5Cn4xoaLEWma3OBNK/3bAZEIiq ft4LW7uBkSPzhE9Cgh9E0lSXO0dR5bCd58lhUL2jdwWPLkWCXNOuCARfCvqqO0n+Rl9GwBt eN1Ngbd0dOAMC3Njdg9Vg== X-UI-Out-Filterresults: notjunk:1;V01:K0:5EP6XKxHpMw=:ZgNG+r94C8FdJfSTt/UySq ZV10eRjIo8FGiRavj0opcVnoEza91qIn3vp8T15ATNyZ1x6lByK9PbIv3CfgokCMXuNot3W/m tqG8z3y2nxDm4tkHE7ZyOw6dmz1OtCfiQHqMmOZrNqeIZ9htCt5tqOo5+C+Cm7m8HXBB4YIAO d8pk0vYcImfTah8vWavd0AIdtMGhdAY6BxREHHpXLeLZsOyOgtlbYZz8+MCyvoHTbIEnn380/ 3CHmDKNQByCXZ5Gm6svZ3e/VmmX2RN9D1cMmLCiNLbgir+w8+KHxpAPWwd3drUdHDjEUxOV1v 05yyYYg2Hhhp4N8qCUs1qZS7yRUQcSjEDEDLRiOrwMUxbZlrtVycTSLEzg3GefIaC0q0kP66S RD2q4Gh0/rJ6Valw1EiCd3zDfU1LZJYc0YcmQ2i78Zwvg3Aga+gVmqu43OuyPdRXIyei4oyTW brmOjaZfXaNSmw3jbIdoYwnwv/DcX/RI1qfHHDXbD6rW3qtYQvsz7vBAhHqxyTqBTCq76qJ4e FMWVgWtezO1aWQyciZrSPkwClrI8RlT4A3RsBj0OsRG7Ni7PC7sQSDmwO/jgL0EqlokizDbLq c5oa8ldFmKlXL8xNSzKpSfBY9CnEBze3cmB2FidnDpwIo5s5gGiF5wWXHUQupieBLZ0/Qn+N3 8GU7l0m/R+cE1lMl0P4b+0XMaRiavGD2Hi54Zzo/qo5jus7TWbypqNOwQ0kYKJdSi9TvpdLG6 gy97tf8+Xh0hbrhpV7FS4bj275UHswTc9sREq37U36F+21HoiaSYt9f8zXw2v0cU+mp5N6bBT AYv0kXggPB5fGX429e4gbSGmbqVT0ypPa4gxXxsRb38+W4dNsU= X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , Philipp Stephani , 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) Paul Eggert writes: Hi Paul, > By "Tramp quoting" I was referring to the technique you used in > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=28156#23 to create a > symlink whose name starts with "~", by prefixing the name with > "/:/tmp/". I don't know why the "/:" is there ... See the lower part of (info "(elisp) File Name Expansion") Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 04:34:29 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 08:34:29 +0000 Received: from localhost ([127.0.0.1]:47296 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djiAH-000322-1B for submit@debbugs.gnu.org; Mon, 21 Aug 2017 04:34:29 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djiAF-00031q-GU for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 04:34:28 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 63DA91608B3; Mon, 21 Aug 2017 01:34:21 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id YNWNrchSlWGy; Mon, 21 Aug 2017 01:34:20 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id AC8771608A7; Mon, 21 Aug 2017 01:34:20 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id PzYbpTzZE5wT; Mon, 21 Aug 2017 01:34:20 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 861FD160880; Mon, 21 Aug 2017 01:34:20 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Eli Zaretskii References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> <83a82ucaew.fsf@gnu.org> <834lt1d4yh.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <6d4110f8-5c70-6c0f-bbad-dd8cd1d193e3@cs.ucla.edu> Date: Mon, 21 Aug 2017 01:34:20 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <834lt1d4yh.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Eli Zaretskii wrote: > No need to affect its interactive invocation. Yes, that's what npostavs suggested too. I plan to look into it. > (file-symlink-p "/:/tmp/symlink") >=20 > There's special code in file-symlink-p to support this and return a > quoted name of the symlink target. For some reason, you wanted to > remove that code. The proposed change to file-symlink-p doesn't affect support for file nam= e=20 quoting in its argument string. All it affects is the returned string. Th= ere is=20 no need for it to quote the returned string, just as there is no need for= =20 read-file-name to quote the string that it returns. Neither function is=20 documented to quote its return value, and neither should do so. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 10:26:20 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 14:26:20 +0000 Received: from localhost ([127.0.0.1]:47919 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djnel-00089s-QV for submit@debbugs.gnu.org; Mon, 21 Aug 2017 10:26:20 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djneh-00089d-TW for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 10:26:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djneZ-0002fu-KU for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 10:26:10 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56704) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djneZ-0002fk-Gs; Mon, 21 Aug 2017 10:26:07 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1488 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1djneW-0004kT-T6; Mon, 21 Aug 2017 10:26:07 -0400 Date: Mon, 21 Aug 2017 17:25:37 +0300 Message-Id: <83y3qdatge.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <6d4110f8-5c70-6c0f-bbad-dd8cd1d193e3@cs.ucla.edu> (message from Paul Eggert on Mon, 21 Aug 2017 01:34:20 -0700) Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> <83a82ucaew.fsf@gnu.org> <834lt1d4yh.fsf@gnu.org> <6d4110f8-5c70-6c0f-bbad-dd8cd1d193e3@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > Cc: michael.albinus@gmx.de, p.stephani2@gmail.com, 28156@debbugs.gnu.org > From: Paul Eggert > Date: Mon, 21 Aug 2017 01:34:20 -0700 > > The proposed change to file-symlink-p doesn't affect support for file name > quoting in its argument string. All it affects is the returned string. There is > no need for it to quote the returned string What if readlink returns a name such as "/ssh:foo@bar:/quux"? A symlink cannot have a remote file name as its target, can it? So quoting it sounds like a good way to avoid triggering a slow and erroneous connection to some possibly non-existent host. If we don't quote, the caller might be in for a surprise. > just as there is no need for read-file-name to quote the string that > it returns. read-file-name gets the string from the user, so it's an entirely different context. In that context, it's user's responsibility to quote the file name if needed. > Neither function is documented to quote its return value, and > neither should do so. Documentation in Emacs was never 110% accurate, so reading it as a kind of formal requirements is not a good idea, IME. This behavior is in file-symlink-p since more than 17 years ago, so it's a de-facto standard by now; if we decide it is what we want, we could document it and move on. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 11:59:28 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 15:59:28 +0000 Received: from localhost ([127.0.0.1]:48046 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djp6u-0001xj-HS for submit@debbugs.gnu.org; Mon, 21 Aug 2017 11:59:28 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39818) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djp6s-0001xX-TM for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 11:59:27 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D811B1608B2; Mon, 21 Aug 2017 08:59:20 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id FyY99zaes6Js; Mon, 21 Aug 2017 08:59:20 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 28B6A1608AA; Mon, 21 Aug 2017 08:59:20 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id E0cY3DSD57z5; Mon, 21 Aug 2017 08:59:20 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 04337160880; Mon, 21 Aug 2017 08:59:20 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Eli Zaretskii References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <87y3qexfeo.fsf@detlef> <8a526a4a-fd11-06c7-8ad4-bc00a667bcd1@cs.ucla.edu> <83a82ucaew.fsf@gnu.org> <834lt1d4yh.fsf@gnu.org> <6d4110f8-5c70-6c0f-bbad-dd8cd1d193e3@cs.ucla.edu> <83y3qdatge.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Mon, 21 Aug 2017 08:58:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83y3qdatge.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Eli Zaretskii wrote: > What if readlink returns a name such as "/ssh:foo@bar:/quux"? A > symlink cannot have a remote file name as its target, can it? A symlink target is a string, and can have any bytes in it (other than NU= L). So=20 if FOO is a remote file name then it can have FOO as a target. Of course = the OS=20 won't interpret the remote file name on its own, just as it won't interpr= et ~ or=20 $ or whatever, but that is OK and expected. > read-file-name gets the string from the user, so it's an entirely > different context. It was just one example, though it remains a good one. Another example is= =20 (directory-files dir), which does not escape its results even when they b= egin=20 with ~. Really, there is no need or good precedent for the sort of escapi= ng that=20 you propose. It is much simpler (and agrees with the documentation and=20 intuition) for file-symlink-p to return the results as-is, like directory= -files=20 does. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 13:34:38 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 17:34:38 +0000 Received: from localhost ([127.0.0.1]:48122 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djqaz-00062V-SU for submit@debbugs.gnu.org; Mon, 21 Aug 2017 13:34:38 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:52576) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djqax-00062E-Ty for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 13:34:36 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B2243160892; Mon, 21 Aug 2017 10:34:29 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id WvWgHtcN_4ur; Mon, 21 Aug 2017 10:34:28 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5CE461608A7; Mon, 21 Aug 2017 10:34:28 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 8jWQf1y1vvqR; Mon, 21 Aug 2017 10:34:28 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2B2D416083A; Mon, 21 Aug 2017 10:34:28 -0700 (PDT) From: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Eli Zaretskii References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> Organization: UCLA Computer Science Department Message-ID: <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> Date: Mon, 21 Aug 2017 10:34:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83bmnacaob.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------A10EEAAF641D4F6D5B6A3411" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------A10EEAAF641D4F6D5B6A3411 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable >> Quoting does not work for these cases. If I try to rename a symlink to= the >> literal string '~eggert' on my machine, Emacs will misbehave as descri= bed and >> there is no way to quote the string naming the symlink to fix this. >=20 > That is but one use case of many. In other cases, quoting does work. My point is that there is a bug in some cases. I agree that in other case= s,=20 make-symbolic-link does work. > your proposed changes will disallow some of the > users' capabilities to do what you want. With the proposed changes a user can create a local symlink to an any str= ing=20 supported by the operating system. This change increases users' capabilit= ies,=20 compared to what they can do now. This change does not take away any capa= bilities. > they seem to > sacrifice a very common interactive use case on behalf of a much more > rare and obscure one. I'm talking about a user typing this: >=20 > M-x make-symbolic-link RET ~/foo/bar RET /toto/quux RET Good suggestion, also made by others. Revised patch attached. --------------A10EEAAF641D4F6D5B6A3411 Content-Type: text/x-patch; name="0001-Do-not-munge-contents-of-local-symbolic-links.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Do-not-munge-contents-of-local-symbolic-links.patch" =46rom 868a212ba636a7cab27e1ee88495a7f7dcf71b0d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 21 Aug 2017 09:46:34 -0700 Subject: [PATCH] Do not munge contents of local symbolic links This lets Emacs deal with arbitrary local symlinks without mishandling their contents. For example, (progn (shell-command "ln -fs '~' 'x'") (rename-file "x" "/tmp/x")) now consistently creates a symbolic link from '/tmp/x' to '~'. Formerly, it did that only if the working directory was on the same filesystem as /tmp; otherwise, it expanded the '~' to the user's home directory. * etc/NEWS: Document the change. * src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the target unless interactive, and look for special constructs only in the new link name, not the target. (emacs_readlinkat): Do not preprend "/:" to the link target if it starts with "/" and contains ":" before NUL. * test/lisp/net/tramp-tests.el (tramp-test21-file-links): Adjust to new behavior. * test/src/fileio-tests.el (try-link): Rename from try-char, and accept a string instead of a char. All uses changed. (fileio-tests--symlink-failure): Also test leading ~, and "/:", to test the new behavior. --- doc/emacs/files.texi | 7 ++++--- doc/lispref/files.texi | 3 ++- etc/NEWS | 15 +++++++++++++++ src/fileio.c | 21 +++------------------ test/lisp/net/tramp-tests.el | 9 ++++++--- test/src/fileio-tests.el | 21 ++++++++++----------- 6 files changed, 40 insertions(+), 36 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 9195bc4..56e3d2f 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1609,9 +1609,10 @@ Copying and Naming @var{new}, which points at @var{target}. The effect is that future attempts to open file @var{new} will refer to whatever file is named @var{target} at the time the opening is done, or will get an error if -the name @var{target} is nonexistent at that time. This command does -not expand the argument @var{target}, so that it allows you to specify -a relative name as the target of the link. On MS-Windows, this +the name @var{target} is nonexistent at that time. This command +expands the argument @var{target} only if it begins with @samp{~}, so +that it allows you to specify most relative names as the target of the +link. On MS-Windows, this command works only on MS Windows Vista and later. On remote systems, it works depending on the system type. =20 diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 5a52765..11e4b43 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -1725,7 +1725,8 @@ Changing Files This command makes a symbolic link to @var{filename}, named @var{newname}. This is like the shell command @samp{ln -s @var{filename} @var{newname}}. The @var{filename} argument -is treated only as a string; it need not name an existing file. +need not name an existing file, and is expanded only if it begins with @= samp{~} +and @var{ok-if-already-exists} is an integer, indicating interactive use= =2E If @var{filename} is a relative file name, the resulting symbolic link is interpreted relative to the directory containing the symbolic link. @xref{Relative File Names}. diff --git a/etc/NEWS b/etc/NEWS index 0939033..97462ec 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1215,6 +1215,21 @@ instead of to utf-8. Before this change, Emacs wo= uld sometimes mishandle file names containing these control characters. =20 +++ +** 'file-attributes', 'file-symlink-p' and 'make-symbolic-link' no +longer quietly mutate the target of a local symbolic link, so that +Emacs can access and copy them reliably regardless of their contents. +Two changes are involved. First, 'file-attributes' and +'file-symlink-p' no longer prepend "/:" to symbolic links whose +targets begin with "/" and contain ":". For example, if a symbolic +link "x" has a target "/y:z", (file-symlink-p "x") now returns "/y:z" +rather than "/:/y:z". Second, 'make-symbolic-link' now expands a link +target with leading "~" only when the optional third arg is an +integer, as when invoked interactively. For example, with +(make-symbolic-link "~y" "x") the link target is now the string "~y"; +to get the old behavior, use (make-symbolic-link (expand-file-name +"~y") "x"). + ++++ ** Module functions are now implemented slightly differently; in particular, the function 'internal--module-call' has been removed. Code that depends on undocumented internals of the module system might diff --git a/src/fileio.c b/src/fileio.c index f954ac1..ad2aab8 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2415,7 +2415,8 @@ DEFUN ("make-symbolic-link", Fmake_symbolic_link, S= make_symbolic_link, 2, 3, Both args must be strings. Signal a `file-already-exists' error if a file LINKNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. -An integer third arg means request confirmation if LINKNAME already exis= ts. +An integer third arg means request confirmation if LINKNAME +already exists, and expand TARGET if it begins with "~". This happens for interactive use with M-x. */) (Lisp_Object target, Lisp_Object linkname, Lisp_Object ok_if_already_e= xists) { @@ -2423,21 +2424,10 @@ This happens for interactive use with M-x. */) Lisp_Object encoded_target, encoded_linkname; =20 CHECK_STRING (target); - /* If the link target has a ~, we must expand it to get - a truly valid file name. Otherwise, do not expand; - we want to permit links to relative file names. */ - if (SREF (target, 0) =3D=3D '~') + if (INTEGERP (ok_if_already_exists) && SREF (target, 0) =3D=3D '~') target =3D Fexpand_file_name (target, Qnil); - linkname =3D expand_cp_target (target, linkname); =20 - /* If the file name has special constructs in it, - call the corresponding file handler. */ - handler =3D Ffind_file_name_handler (target, Qmake_symbolic_link); - if (!NILP (handler)) - return call4 (handler, Qmake_symbolic_link, target, - linkname, ok_if_already_exists); - /* If the new link name has special constructs in it, call the corresponding file handler. */ handler =3D Ffind_file_name_handler (linkname, Qmake_symbolic_link); @@ -2635,11 +2625,6 @@ emacs_readlinkat (int fd, char const *filename) return Qnil; =20 val =3D build_unibyte_string (buf); - if (buf[0] =3D=3D '/' && strchr (buf, ':')) - { - AUTO_STRING (slash_colon, "/:"); - val =3D concat2 (slash_colon, val); - } if (buf !=3D readlink_buf) xfree (buf); val =3D DECODE_FILE (val); diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 129bc1d..8c0c8c8 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2538,13 +2538,16 @@ tramp--test-backtrace (should-error (make-symbolic-link tmp-name1 tmp-name2)) (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists) (should (file-symlink-p tmp-name2)) - ;; `tmp-name3' is a local file name. - (should-error (make-symbolic-link tmp-name1 tmp-name3))) + ;; `tmp-name3' is a local file name, so its target is not + ;; interpreted. + (make-symbolic-link tmp-name1 tmp-name3) + (should (equal tmp-name1 (file-symlink-p tmp-name3)))) =20 ;; Cleanup. (ignore-errors (delete-file tmp-name1) - (delete-file tmp-name2))) + (delete-file tmp-name2) + (delete-file tmp-name3))) =20 ;; Check `add-name-to-file'. (unwind-protect diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 2ef1b55..5103d2f 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -19,14 +19,13 @@ =20 (require 'ert) =20 -(defun try-char (char link) - (let ((target (string char))) - (make-symbolic-link target link) - (let* ((read-link (file-symlink-p link)) - (failure (unless (string-equal target read-link) - (list 'string-equal target read-link)))) - (delete-file link) - failure))) +(defun try-link (target link) + (make-symbolic-link target link) + (let* ((read-link (file-symlink-p link)) + (failure (unless (string-equal target read-link) + (list 'string-equal target read-link)))) + (delete-file link) + failure)) =20 (defun fileio-tests--symlink-failure () (let* ((dir (make-temp-file "fileio" t)) @@ -36,9 +35,9 @@ fileio-tests--symlink-failure (char 0)) (while (and (not failure) (< char 127)) (setq char (1+ char)) - (unless (=3D char ?~) - (setq failure (try-char char link)))) - failure) + (setq failure (try-link (string char) link))) + (or failure + (try-link "/:" link))) (delete-directory dir t)))) =20 (ert-deftest fileio-tests--odd-symlink-chars () --=20 2.7.4 --------------A10EEAAF641D4F6D5B6A3411-- From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 14:00:04 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 18:00:04 +0000 Received: from localhost ([127.0.0.1]:48130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djqzb-0006aw-G0 for submit@debbugs.gnu.org; Mon, 21 Aug 2017 14:00:03 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50724) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djqzY-0006Zw-SN for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 14:00:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1djqzP-0005Kz-KY for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 13:59:55 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:36398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1djqzP-0005Kq-HJ; Mon, 21 Aug 2017 13:59:51 -0400 Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1692 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1djqzO-0001Fd-N9; Mon, 21 Aug 2017 13:59:51 -0400 Date: Mon, 21 Aug 2017 20:59:43 +0300 Message-Id: <83bmn8by40.fsf@gnu.org> From: Eli Zaretskii To: Paul Eggert In-reply-to: <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> (message from Paul Eggert on Mon, 21 Aug 2017 10:34:27 -0700) Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Eli Zaretskii Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) > From: Paul Eggert > Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org > Date: Mon, 21 Aug 2017 10:34:27 -0700 > > - /* If the file name has special constructs in it, > - call the corresponding file handler. */ > - handler = Ffind_file_name_handler (target, Qmake_symbolic_link); > - if (!NILP (handler)) > - return call4 (handler, Qmake_symbolic_link, target, > - linkname, ok_if_already_exists); > - Why remove this part? You also did not mentioned that in NEWS. Thanks. From debbugs-submit-bounces@debbugs.gnu.org Mon Aug 21 16:30:18 2017 Received: (at 28156) by debbugs.gnu.org; 21 Aug 2017 20:30:18 +0000 Received: from localhost ([127.0.0.1]:48230 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djtL0-0001rM-AK for submit@debbugs.gnu.org; Mon, 21 Aug 2017 16:30:18 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:47342) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djtKy-0001r7-7F for 28156@debbugs.gnu.org; Mon, 21 Aug 2017 16:30:17 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2970B1608C9; Mon, 21 Aug 2017 13:30:10 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id gI_e6TJEj12g; Mon, 21 Aug 2017 13:30:08 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id D09BF1608C7; Mon, 21 Aug 2017 13:30:08 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id vxHxjfS__d02; Mon, 21 Aug 2017 13:30:08 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id A668D1608C4; Mon, 21 Aug 2017 13:30:08 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Eli Zaretskii References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> Date: Mon, 21 Aug 2017 13:30:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <83bmn8by40.fsf@gnu.org> Content-Type: multipart/mixed; boundary="------------77FF4728353410E98C2E4EB8" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: p.stephani2@gmail.com, michael.albinus@gmx.de, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------77FF4728353410E98C2E4EB8 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Eli Zaretskii wrote: > Why remove this part? You also did not mentioned that in NEWS. The symlink target is a string not a file name, so giving it to file name= =20 handler can cause the make-symbolic-link call to be misinterpreted. Revis= ed NEWS=20 in attached patch, with an example. --------------77FF4728353410E98C2E4EB8 Content-Type: text/x-patch; name="0001-Do-not-munge-contents-of-local-symbolic-links.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Do-not-munge-contents-of-local-symbolic-links.patch" =46rom 6c8d19b8ab7db320db844c14b034923cf43a194c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 21 Aug 2017 09:46:34 -0700 Subject: [PATCH] Do not munge contents of local symbolic links This lets Emacs deal with arbitrary local symlinks without mishandling their contents. For example, (progn (shell-command "ln -fs '~' 'x'") (rename-file "x" "/tmp/x")) now consistently creates a symbolic link from '/tmp/x' to '~'. Formerly, it did that only if the working directory was on the same filesystem as /tmp; otherwise, it expanded the '~' to the user's home directory. * etc/NEWS: Document the change. * src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the target unless interactive, and look for special constructs only in the new link name, not the target. (emacs_readlinkat): Do not preprend "/:" to the link target if it starts with "/" and contains ":" before NUL. * test/lisp/net/tramp-tests.el (tramp-test21-file-links): Adjust to new behavior. * test/src/fileio-tests.el (try-link): Rename from try-char, and accept a string instead of a char. All uses changed. (fileio-tests--symlink-failure): Also test leading ~, and "/:", to test the new behavior. --- doc/emacs/files.texi | 7 ++++--- doc/lispref/files.texi | 3 ++- etc/NEWS | 21 +++++++++++++++++++++ src/fileio.c | 21 +++------------------ test/lisp/net/tramp-tests.el | 9 ++++++--- test/src/fileio-tests.el | 21 ++++++++++----------- 6 files changed, 46 insertions(+), 36 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 9195bc4..56e3d2f 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1609,9 +1609,10 @@ Copying and Naming @var{new}, which points at @var{target}. The effect is that future attempts to open file @var{new} will refer to whatever file is named @var{target} at the time the opening is done, or will get an error if -the name @var{target} is nonexistent at that time. This command does -not expand the argument @var{target}, so that it allows you to specify -a relative name as the target of the link. On MS-Windows, this +the name @var{target} is nonexistent at that time. This command +expands the argument @var{target} only if it begins with @samp{~}, so +that it allows you to specify most relative names as the target of the +link. On MS-Windows, this command works only on MS Windows Vista and later. On remote systems, it works depending on the system type. =20 diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 5a52765..11e4b43 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -1725,7 +1725,8 @@ Changing Files This command makes a symbolic link to @var{filename}, named @var{newname}. This is like the shell command @samp{ln -s @var{filename} @var{newname}}. The @var{filename} argument -is treated only as a string; it need not name an existing file. +need not name an existing file, and is expanded only if it begins with @= samp{~} +and @var{ok-if-already-exists} is an integer, indicating interactive use= =2E If @var{filename} is a relative file name, the resulting symbolic link is interpreted relative to the directory containing the symbolic link. @xref{Relative File Names}. diff --git a/etc/NEWS b/etc/NEWS index 0939033..39c34fa 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1215,6 +1215,27 @@ instead of to utf-8. Before this change, Emacs wo= uld sometimes mishandle file names containing these control characters. =20 +++ +** 'file-attributes', 'file-symlink-p' and 'make-symbolic-link' no +longer quietly mutate the target of a local symbolic link, so that +Emacs can access and copy them reliably regardless of their contents. +The following changes are involved. + +*** 'file-attributes' and 'file-symlink-p' no longer prepend "/:" to +symbolic links whose targets begin with "/" and contain ":". For +example, if a symbolic link "x" has a target "/y:z", (file-symlink-p +"x") now returns "/y:z" rather than "/:/y:z". + +*** 'make-symbolic-link' no longer looks for file name handlers when +creating a local symbolic link. For example, (make-symbolic-link +"/y:z" "x") now creates a symlink to "/y:z" instead of failing. + +*** 'make-symbolic-link' now expands a link target with leading "~" +only when the optional third arg is an integer, as when invoked +interactively. For example, with (make-symbolic-link "~y" "x") the +link target is now the string "~y"; to get the old behavior, use +(make-symbolic-link (expand-file-name "~y") "x"). + ++++ ** Module functions are now implemented slightly differently; in particular, the function 'internal--module-call' has been removed. Code that depends on undocumented internals of the module system might diff --git a/src/fileio.c b/src/fileio.c index f954ac1..ad2aab8 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2415,7 +2415,8 @@ DEFUN ("make-symbolic-link", Fmake_symbolic_link, S= make_symbolic_link, 2, 3, Both args must be strings. Signal a `file-already-exists' error if a file LINKNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. -An integer third arg means request confirmation if LINKNAME already exis= ts. +An integer third arg means request confirmation if LINKNAME +already exists, and expand TARGET if it begins with "~". This happens for interactive use with M-x. */) (Lisp_Object target, Lisp_Object linkname, Lisp_Object ok_if_already_e= xists) { @@ -2423,21 +2424,10 @@ This happens for interactive use with M-x. */) Lisp_Object encoded_target, encoded_linkname; =20 CHECK_STRING (target); - /* If the link target has a ~, we must expand it to get - a truly valid file name. Otherwise, do not expand; - we want to permit links to relative file names. */ - if (SREF (target, 0) =3D=3D '~') + if (INTEGERP (ok_if_already_exists) && SREF (target, 0) =3D=3D '~') target =3D Fexpand_file_name (target, Qnil); - linkname =3D expand_cp_target (target, linkname); =20 - /* If the file name has special constructs in it, - call the corresponding file handler. */ - handler =3D Ffind_file_name_handler (target, Qmake_symbolic_link); - if (!NILP (handler)) - return call4 (handler, Qmake_symbolic_link, target, - linkname, ok_if_already_exists); - /* If the new link name has special constructs in it, call the corresponding file handler. */ handler =3D Ffind_file_name_handler (linkname, Qmake_symbolic_link); @@ -2635,11 +2625,6 @@ emacs_readlinkat (int fd, char const *filename) return Qnil; =20 val =3D build_unibyte_string (buf); - if (buf[0] =3D=3D '/' && strchr (buf, ':')) - { - AUTO_STRING (slash_colon, "/:"); - val =3D concat2 (slash_colon, val); - } if (buf !=3D readlink_buf) xfree (buf); val =3D DECODE_FILE (val); diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 129bc1d..8c0c8c8 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2538,13 +2538,16 @@ tramp--test-backtrace (should-error (make-symbolic-link tmp-name1 tmp-name2)) (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists) (should (file-symlink-p tmp-name2)) - ;; `tmp-name3' is a local file name. - (should-error (make-symbolic-link tmp-name1 tmp-name3))) + ;; `tmp-name3' is a local file name, so its target is not + ;; interpreted. + (make-symbolic-link tmp-name1 tmp-name3) + (should (equal tmp-name1 (file-symlink-p tmp-name3)))) =20 ;; Cleanup. (ignore-errors (delete-file tmp-name1) - (delete-file tmp-name2))) + (delete-file tmp-name2) + (delete-file tmp-name3))) =20 ;; Check `add-name-to-file'. (unwind-protect diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 2ef1b55..5103d2f 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -19,14 +19,13 @@ =20 (require 'ert) =20 -(defun try-char (char link) - (let ((target (string char))) - (make-symbolic-link target link) - (let* ((read-link (file-symlink-p link)) - (failure (unless (string-equal target read-link) - (list 'string-equal target read-link)))) - (delete-file link) - failure))) +(defun try-link (target link) + (make-symbolic-link target link) + (let* ((read-link (file-symlink-p link)) + (failure (unless (string-equal target read-link) + (list 'string-equal target read-link)))) + (delete-file link) + failure)) =20 (defun fileio-tests--symlink-failure () (let* ((dir (make-temp-file "fileio" t)) @@ -36,9 +35,9 @@ fileio-tests--symlink-failure (char 0)) (while (and (not failure) (< char 127)) (setq char (1+ char)) - (unless (=3D char ?~) - (setq failure (try-char char link)))) - failure) + (setq failure (try-link (string char) link))) + (or failure + (try-link "/:" link))) (delete-directory dir t)))) =20 (ert-deftest fileio-tests--odd-symlink-chars () --=20 2.7.4 --------------77FF4728353410E98C2E4EB8-- From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 22 03:28:50 2017 Received: (at 28156) by debbugs.gnu.org; 22 Aug 2017 07:28:50 +0000 Received: from localhost ([127.0.0.1]:48522 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dk3cI-0001u1-Lk for submit@debbugs.gnu.org; Tue, 22 Aug 2017 03:28:50 -0400 Received: from mout.gmx.net ([212.227.17.20]:56260) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dk3cG-0001to-GZ for 28156@debbugs.gnu.org; Tue, 22 Aug 2017 03:28:49 -0400 Received: from detlef.gmx.de ([212.86.50.207]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0Las1k-1dHLdf0NU8-00kT8a; Tue, 22 Aug 2017 09:28:31 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> Date: Tue, 22 Aug 2017 09:28:28 +0200 In-Reply-To: <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> (Paul Eggert's message of "Mon, 21 Aug 2017 13:30:08 -0700") Message-ID: <87tw10qcwz.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:qeOPCfrdGsVifip8Exq+A1V8KPCyahIiiwJZIMDTtkua6j9aVke C5d0FvB6GlwVufITh/hz9CKJj65e3hLTSFyTIl8L6/UdUMDK1VrSc9d0oHxykaQZcLI+PK3 3lTW6rQZ+neZbpaojZVEcIvWkiJMUhIge9HnGqx8vQEWUmbJ6g+IQeYmIgx9itj4fximKJn B7oVlmSeUemGPTYaI3m/Q== X-UI-Out-Filterresults: notjunk:1;V01:K0:rPH3kaxUJGU=:cY5D04P77gA6BqmrqgGxi/ AH06Tgfqwa1DZgHUnyrkzwsRD7x7p554DPawRUaOhLJK4tCYTc3yv8494M0IudlQm8EMKIeF8 Uah1Z+m+VqMgM8pGhWAeUE6Nc+JhJGx38MwTsQbaWkfbp8FrhE32qwCJ2fqdqF1tIb1Zi1Ujv HmQlbZKuEF9k0UC9hwaxzQqxzTrE3sIZCAwlEFOJFhQ0OaYE3AjzScREiTlwVl26RpcHdF1gS WYRzBxt1FWHSDO+IeM6arpmQVzk6rrniN2WqJUsUrlSYWXDy0bU4pKH3wFKKcdRAiAwBwFLMv VdTV2B00W0rc53kFQG0hGLFgNj0AZ16U6/3KXXibIrIrbuVQKrz7A4+67QuXWpIuhVJjdxXzK vrZrJ3c85d7/6XU5e3OqrnhSCgSg9nkxqggJIZhygTDXBlW6mjZ36yfKcSUElHyVT0kKge1ui EUnvOml3dAuCM64Hg74XUGcw3Up5p5frazKezZpVue0zs/AaTtP9KW7dOsLzDzKz71CZxwJM4 yINHGDhfk/BMHj7jqLxIMlfQWPlYCk2X8y0yopI7CHy6qwAeiYT8+di4MM7Vq/K1J5T88yqgx QANTCLbKZIjGD0BfxbHUgSH5qC+oaRfRTNes5QxlIyNnhbOZ0q51IDMYZd1FwaW+teLfwRH5y zaHe89vzcRrZfN1yo99TXEzk/zCmglHqaWkq5CzVRiyTXzlTjECQqX3XSufiL47T3NjVeG4nE 1T0mUBCTx58+wSbrpY24UBx/XSqyyK25VqSBxb+TEScNE2kmGa2Zkb2dcrhjdd6i/bKolvO82 ZHjGCQz9zJTX2CoAcqAjy4DrNwqeK4ZV+5ONLP9W1E90ziI4Yc= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , p.stephani2@gmail.com, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Paul Eggert writes: Hi Paul, > The symlink target is a string not a file name, so giving it to file > name handler can cause the make-symbolic-link call to be > misinterpreted. If you want to have an absolute filename as LINKNAME, you typically call (make-symbolic-link (expand-file-name target) (expand-file-name linkname)) In case of remote file names, (expand-file-name linkname) will always return something like "/method:user@host:/path/to/linkname". I doubt, that a user wants to see this literal string as symbolic link. Furthermore, there is the OK-IF-ALREADY-EXISTS argument of make-symbolic-string. This requires to regard LINKNAME as a file name, and not as a literal string. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Aug 22 12:04:02 2017 Received: (at 28156) by debbugs.gnu.org; 22 Aug 2017 16:04:02 +0000 Received: from localhost ([127.0.0.1]:49754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkBes-000155-06 for submit@debbugs.gnu.org; Tue, 22 Aug 2017 12:04:02 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:56662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkBeq-00014i-Hs for 28156@debbugs.gnu.org; Tue, 22 Aug 2017 12:04:01 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C80F916088A; Tue, 22 Aug 2017 09:03:53 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id mTRF2Gtn8BKu; Tue, 22 Aug 2017 09:03:53 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0B539160878; Tue, 22 Aug 2017 09:03:53 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UgNZ7Iu-cnGB; Tue, 22 Aug 2017 09:03:52 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E5393160094; Tue, 22 Aug 2017 09:03:52 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Michael Albinus References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> <87tw10qcwz.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <787f2dca-7135-3da5-4516-99d12ecf8edd@cs.ucla.edu> Date: Tue, 22 Aug 2017 09:03:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87tw10qcwz.fsf@detlef> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , p.stephani2@gmail.com, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) On 08/22/2017 12:28 AM, Michael Albinus wrote: > If you want to have an absolute filename as LINKNAME, you typically call > > (make-symbolic-link (expand-file-name target) (expand-file-name linkname)) > > In case of remote file names, (expand-file-name linkname) will always > return something like "/method:user@host:/path/to/linkname". I doubt, > that a user wants to see this literal string as symbolic link. There seems to be some confusion here, as Bug#28156 does not propose any change to how make-symbolic-link's 2nd argument works, (expand-file-name linkname) in this case. If the 2nd argument specifies a remote name, as in your example, then Tramp will take over and do whatever it wants with both arguments, so Bug#28156 is not proposing any change there (although perhaps some changes would be helpful for consistency, that's a different matter). Bug#28156 is proposing changes only when the new linkname is local, and in those cases, if I'm not mistaken, Emacs currently errors out when the target looks like it is remote, so Bug#28156 is merely proposing an extension. Emacs routinely creates dangling symlinks with targets containing unusual characters like ":", and it wouldn't be surprising if users wanted to do something similar on their own. > Furthermore, there is the OK-IF-ALREADY-EXISTS argument of > make-symbolic-string. This requires to regard LINKNAME as a file name, > and not as a literal string. That's fine, as Bug#28156 is not proposing any change here. LINKNAME continues to be treated as a file name under the proposed change. The proposed change affects only symlink contents, not symlink names. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 24 07:38:54 2017 Received: (at 28156) by debbugs.gnu.org; 24 Aug 2017 11:38:54 +0000 Received: from localhost ([127.0.0.1]:52221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkqTO-00044J-As for submit@debbugs.gnu.org; Thu, 24 Aug 2017 07:38:54 -0400 Received: from mout.gmx.net ([212.227.17.21]:58268) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dkqTK-000444-PH for 28156@debbugs.gnu.org; Thu, 24 Aug 2017 07:38:53 -0400 Received: from detlef.gmx.de ([178.20.93.162]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MIdYi-1didXc35Oy-002KOv; Thu, 24 Aug 2017 13:38:33 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> <87tw10qcwz.fsf@detlef> <787f2dca-7135-3da5-4516-99d12ecf8edd@cs.ucla.edu> Date: Thu, 24 Aug 2017 13:38:29 +0200 In-Reply-To: <787f2dca-7135-3da5-4516-99d12ecf8edd@cs.ucla.edu> (Paul Eggert's message of "Tue, 22 Aug 2017 09:03:52 -0700") Message-ID: <87a82p8abu.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:PHy3nfCDdjAMt9jcRmdjGuFoHou2BoCMxHwArWn5MPbj//zmEiL YR+9BGICkO51gCfdklvOo36XvRwPawEwxjhryXMQ0xDoDttm1/RStezOgoDd7iROLAV11Uf Dlm9W8JHLQ8vUbfJcB8KUH/8VZyxU7kH8NRtdSps+CYZOCWZmPOm9tNF0igzI9jMJ3hxr6H 4PRlAyWjUilXM6HLsaccA== X-UI-Out-Filterresults: notjunk:1;V01:K0:k64UMCb0wSk=:/BROMZSSmT4y1jmARynyvj xUdcVGJOxj/AXwG8mK+lPuzSz0nuwI2D96Pf847UDZPnPSpLQ/Phmc3VVfOHlMoT7zJ8TmHcD QNCCK/QSZLykU+X37/wLCqEJhzCDhN3aGjLTPoOh0qJyP2/AOkwAENzHbRQL4+4wQTSwTOZYy QmnJrLQdOuxx3NiEGBV3LX07FUEry1Wy0x1RKn/U/Y5hQEDoc2LAU/H5XTpSo9q+Cf9wpVgB7 hS7Y8PRRN3dCOR49WIDdB4lkfAAwOOnJZbY2PBXCg52iZOLfSohSLMUEjFVVEitqaBBjqNcDz eZLSOLjn/TZuQMXbI/FwJA6CZNpyfVRwR6ysZF1eO52zUfYXDF9yEIrgb+AqOMBHHIDaV4ed1 jYRRMp5lQ1HsvbtVMYC8gMBMnT/bAz5ESg68RuN1kDUK8HyE1IClwCa5rKCrz7bmvC/4TnuRr y1Pbld5VLntCd5e8A+2GGyq9YwdBMmodkF183ZdUbkIxgW/tOPUQctMwEjkycutGZJVqd+2Hz Tss4wTQMswBrd/68KMcMWZFvifwPjhzrmKp/CSuA0AIIGBFpR83sJOhAVJwT6njedVjPp/x2f hE7V8koaYvG3+w0Rh5rg53BC9QGbEm69o52tP6G8dH00924e/Gf387gqyd/V4v3HmAslth3Hw gXX8z6Y+eizYDk38ajuk+baA5r77eE8zfd/JMfSVCaJofwWPIE5gBxF9IniJe6ZFEblBv11Kz Ii0bEqlozsBKXqX6vl/GBsvrYM0CG+H8d1YXYHTWEmb6n++O7K6baefGe1CmdpiKY4wahEQm2 r2hXsNUIXfSWky+LUO3b2JYyQcADR+5266lYNODgu/62ilcrCI= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , p.stephani2@gmail.com, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Paul Eggert writes: > On 08/22/2017 12:28 AM, Michael Albinus wrote: >> If you want to have an absolute filename as LINKNAME, you typically call >> >> (make-symbolic-link (expand-file-name target) (expand-file-name linkname)) >> >> In case of remote file names, (expand-file-name linkname) will always >> return something like "/method:user@host:/path/to/linkname". I doubt, >> that a user wants to see this literal string as symbolic link. > > There seems to be some confusion here, as Bug#28156 does not propose > any change to how make-symbolic-link's 2nd argument works, > (expand-file-name linkname) in this case. If the 2nd argument > specifies a remote name, as in your example, then Tramp will take over > and do whatever it wants with both arguments, so Bug#28156 is not > proposing any change there (although perhaps some changes would be > helpful for consistency, that's a different matter). Sorry, I have confused the 1st and 2nd argument of make-symbolic-link. Tramp's docstring is wrong, because it does the same error, for decades. Will fix it. However, it is Tramp's (almost undocumented) make-symbolic-link implementation to handle TARGET as well, and to strip the remote part of this. I wouldn't be surprised if existing packages will be broken if we change this. Coming to your examples, I believe the existing implementation gives you almost all what is needed, with quoting. Using "~" in TARGET: --8<---------------cut here---------------start------------->8--- M-x make-symbolic-link RET /:~eggert RET /tmp/foo RET # ls -l /tmp/foo lrwxrwxrwx 1 albinus albinus 21 Aug 24 13:19 /tmp/foo -> /home/albinus/~eggert --8<---------------cut here---------------end--------------->8--- It is questionable whether "/:~eggert" shall be expanded to "/home/albinus/~eggert". I agree with you, that it shouldn't, the target shall be just "~eggert". Using ":" in TARGET would look like: --8<---------------cut here---------------start------------->8--- M-x make-symbolic-link RET /:/x:y RET /tmp/foo RET # ls -l /tmp/foo lrwxrwxrwx 1 albinus albinus 4 Aug 24 13:23 /tmp/foo -> /x:y --8<---------------cut here---------------end--------------->8--- For a TARGET which looks like a remote file name, I propose to keep the current behaviour (stripping the remote part). It shall be equivalent to just using the local file name of TARGET. So we would have: --8<---------------cut here---------------start------------->8--- M-x make-symbolic-link RET /sudo::/:~eggert RET /sudo::/tmp/bar RET # ls -l /tmp/bar lrwxrwxrwx 1 root root 7 Aug 24 13:26 /tmp/bar -> ~eggert ;; This example does not work yet. M-x make-symbolic-link RET /:~eggert RET /sudo::/tmp/bar RET # ls -l /tmp/bar lrwxrwxrwx 1 root root 7 Aug 24 13:26 /tmp/bar -> ~eggert --8<---------------cut here---------------end--------------->8--- --8<---------------cut here---------------start------------->8--- M-x make-symbolic-link RET /sudo::/:/x:y RET /sudo::/tmp/bar RET # ls -l /tmp/foo lrwxrwxrwx 1 root root 4 Aug 24 13:30 /tmp/bar -> /x:y ;; This example does not work yet. M-x make-symbolic-link RET /:/x:y RET /sudo::/tmp/bar RET # ls -l /tmp/foo lrwxrwxrwx 1 root root 4 Aug 24 13:30 /tmp/bar -> /x:y --8<---------------cut here---------------end--------------->8--- By this, you don't need to handle "~" special in make-symbolic-link, as your patch proposes. After all, it is just proper file name quoting, and fixing the bug mentioned above. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 25 01:12:40 2017 Received: (at 28156) by debbugs.gnu.org; 25 Aug 2017 05:12:41 +0000 Received: from localhost ([127.0.0.1]:53452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dl6vA-0004dE-Ap for submit@debbugs.gnu.org; Fri, 25 Aug 2017 01:12:40 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39500) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dl6v7-0004cz-IW for 28156@debbugs.gnu.org; Fri, 25 Aug 2017 01:12:38 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id A29F31608ED; Thu, 24 Aug 2017 22:12:30 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id j5g_b6hyBZmM; Thu, 24 Aug 2017 22:12:29 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 288111608F0; Thu, 24 Aug 2017 22:12:29 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XCq9ZtZK1-Lk; Thu, 24 Aug 2017 22:12:29 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id EC1EF1608B5; Thu, 24 Aug 2017 22:12:28 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Michael Albinus References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> <87tw10qcwz.fsf@detlef> <787f2dca-7135-3da5-4516-99d12ecf8edd@cs.ucla.edu> <87a82p8abu.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <732853c9-87db-e108-edb9-cf581fc62e67@cs.ucla.edu> Date: Thu, 24 Aug 2017 22:12:28 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87a82p8abu.fsf@detlef> Content-Type: multipart/mixed; boundary="------------98856F137A45DD1AD208EE77" Content-Language: en-US X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , p.stephani2@gmail.com, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) This is a multi-part message in MIME format. --------------98856F137A45DD1AD208EE77 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Michael Albinus wrote: > it is Tramp's (almost undocumented) make-symbolic-link > implementation to handle TARGET as well, and to strip the remote part o= f > this. I wouldn't be surprised if existing packages will be broken if we > change this. That should not be a problem with the proposed patch, as it does not affe= ct how=20 Tramp handles TARGET when making a remote symlink. > --8<---------------cut here---------------start------------->8--- > M-x make-symbolic-link RET /:~eggert RET /tmp/foo RET >=20 > # ls -l /tmp/foo > lrwxrwxrwx 1 albinus albinus 21 Aug 24 13:19 /tmp/foo -> /home/albinus/= ~eggert > --8<---------------cut here---------------end--------------->8--- >=20 > It is questionable whether "/:~eggert" shall be expanded to > "/home/albinus/~eggert". I agree with you, that it shouldn't, the targe= t > shall be just "~eggert". Yes, adding support for /: for interactive use sounds reasonable. I updat= ed the=20 patch to do that; please see attached. > For a TARGET which looks like a remote file name, I propose to keep the > current behaviour (stripping the remote part). That's fine if LINKNAME is also remote, since symlinks act locally. That = is, if=20 TARGET and LINKNAME are both remote to the same filesystem, Tramp can con= tinue=20 to munge TARGET so that it works on that filesystem. However, Tramp shoul= d not=20 be in the business of specifying symlink behavior for local symbolic link= s. It=20 should let the OS do that. If LINKNAME is local, TARGET should just act a= s=20 itself without Tramp getting in the way. > it is just proper file name quoting The target of a local symbolic link is a string. It need not name a file,= and=20 often does not name a file. Trying to apply some file name rules to it, a= nd not=20 others, is confusing and leads to broken code. For backward compatibility= we=20 appear to need to handle leading ~ in interactive use and to provide an e= scape=20 for leading ~, but let's not try to inflict these complex rules on code. = For=20 code, make-symbolic-link should just treat a local target as a string, th= e way=20 the OS does. --------------98856F137A45DD1AD208EE77 Content-Type: text/x-patch; name="0001-Do-not-munge-contents-of-local-symbolic-links.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Do-not-munge-contents-of-local-symbolic-links.patch" =46rom 743ab11913b9caa979f9dca8ab2578d9e3de9022 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 24 Aug 2017 16:22:12 -0700 Subject: [PATCH] Do not munge contents of local symbolic links This lets Emacs deal with arbitrary local symlinks without mishandling their contents. For example, (progn (shell-command "ln -fs '~' 'x'") (rename-file "x" "/tmp/x")) now consistently creates a symbolic link from '/tmp/x' to '~'. Formerly, it did that only if the working directory was on the same filesystem as /tmp; otherwise, it expanded the '~' to the user's home directory. * src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the target unless interactive. Strip leading "/:" if interactive. (emacs_readlinkat): Do not preprend "/:" to the link target if it starts with "/" and contains ":" before NUL. * test/lisp/net/tramp-tests.el (tramp-test21-file-links): Adjust to new behavior. * test/src/fileio-tests.el (try-link): Rename from try-char, and accept a string instead of a char. All uses changed. (fileio-tests--symlink-failure): Also test leading ~, and "/:", to test the new behavior. --- doc/emacs/files.texi | 8 ++++++-- doc/lispref/files.texi | 11 +++++++---- etc/NEWS | 24 ++++++++++++++++++++++++ src/fileio.c | 28 +++++++++------------------- test/lisp/net/tramp-tests.el | 9 ++++++--- test/src/fileio-tests.el | 21 ++++++++++----------- 6 files changed, 62 insertions(+), 39 deletions(-) diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 9195bc4..fa1f9e5 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi @@ -1611,8 +1611,12 @@ Copying and Naming @var{target} at the time the opening is done, or will get an error if the name @var{target} is nonexistent at that time. This command does not expand the argument @var{target}, so that it allows you to specify -a relative name as the target of the link. On MS-Windows, this -command works only on MS Windows Vista and later. On remote systems, +a relative name as the target of the link. However, this command +does expand leading @samp{~} in @var{target} so that you can easily +specify home directories, and strips leading @samp{/:} so that you can +specify relative names beginning with literal @samp{~} or @samp{/:}. +@xref{Quoted File Names}. On MS-Windows, this command works only on +MS Windows Vista and later. When @var{new} is remote, it works depending on the system type. =20 @node Misc File Ops diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index 5a52765..054036d 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi @@ -1719,14 +1719,17 @@ Changing Files SELinux context are not copied over in either case. @end deffn =20 -@deffn Command make-symbolic-link filename newname &optional ok-if-alrea= dy-exists +@deffn Command make-symbolic-link target newname &optional ok-if-already= -exists @pindex ln @kindex file-already-exists -This command makes a symbolic link to @var{filename}, named +This command makes a symbolic link to @var{target}, named @var{newname}. This is like the shell command @samp{ln -s -@var{filename} @var{newname}}. The @var{filename} argument +@var{target} @var{newname}}. The @var{target} argument is treated only as a string; it need not name an existing file. -If @var{filename} is a relative file name, the resulting symbolic link +If @var{ok-if-already-exists} is an integer, indicating interactive +use, then leading @samp{~} is expanded and leading @samp{/:} is +stripped in the @var{target} string. +If @var{target} is a relative file name, the resulting symbolic link is interpreted relative to the directory containing the symbolic link. @xref{Relative File Names}. =20 diff --git a/etc/NEWS b/etc/NEWS index bf59749..60ddf54 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1228,6 +1228,30 @@ instead of to utf-8. Before this change, Emacs wo= uld sometimes mishandle file names containing these control characters. =20 +++ +** 'file-attributes', 'file-symlink-p' and 'make-symbolic-link' no +longer quietly mutate the target of a local symbolic link, so that +Emacs can access and copy them reliably regardless of their contents. +The following changes are involved. + +*** 'file-attributes' and 'file-symlink-p' no longer prepend "/:" to +symbolic links whose targets begin with "/" and contain ":". For +example, if a symbolic link "x" has a target "/y:z", (file-symlink-p +"x") now returns "/y:z" rather than "/:/y:z". + +*** 'make-symbolic-link' no longer looks for file name handlers when +creating a local symbolic link. For example, (make-symbolic-link +"/y:z" "x") now creates a symlink to "/y:z" instead of failing. + +*** 'make-symbolic-link' now expands a link target with leading "~" +only when the optional third arg is an integer, as when invoked +interactively. For example, (make-symbolic-link "~y" "x") now creates +a link with target the literal string "~y"; to get the old behavior, +use (make-symbolic-link (expand-file-name "~y") "x"). To avoid this +expansion in interactive use, you can now prefix the link target with +"/:". For example, (make-symbolic-link "/:~y" "x" 1) now creates a +link to literal "~y". + ++++ ** Module functions are now implemented slightly differently; in particular, the function 'internal--module-call' has been removed. Code that depends on undocumented internals of the module system might diff --git a/src/fileio.c b/src/fileio.c index ca1bc50..1e4ccd4 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -2415,7 +2415,8 @@ DEFUN ("make-symbolic-link", Fmake_symbolic_link, S= make_symbolic_link, 2, 3, Both args must be strings. Signal a `file-already-exists' error if a file LINKNAME already exists unless optional third argument OK-IF-ALREADY-EXISTS is non-nil. -An integer third arg means request confirmation if LINKNAME already exis= ts. +An integer third arg means request confirmation if LINKNAME already +exists, and expand leading "~" or strip leading "/:" in TARGET. This happens for interactive use with M-x. */) (Lisp_Object target, Lisp_Object linkname, Lisp_Object ok_if_already_e= xists) { @@ -2423,21 +2424,15 @@ This happens for interactive use with M-x. */) Lisp_Object encoded_target, encoded_linkname; =20 CHECK_STRING (target); - /* If the link target has a ~, we must expand it to get - a truly valid file name. Otherwise, do not expand; - we want to permit links to relative file names. */ - if (SREF (target, 0) =3D=3D '~') - target =3D Fexpand_file_name (target, Qnil); - + if (INTEGERP (ok_if_already_exists)) + { + if (SREF (target, 0) =3D=3D '~') + target =3D Fexpand_file_name (target, Qnil); + else if (SREF (target, 0) =3D=3D '/' && SREF (target, 1) =3D=3D ':= ') + target =3D Fsubstring_no_properties (target, make_number (2), Qnil); + } linkname =3D expand_cp_target (target, linkname); =20 - /* If the file name has special constructs in it, - call the corresponding file handler. */ - handler =3D Ffind_file_name_handler (target, Qmake_symbolic_link); - if (!NILP (handler)) - return call4 (handler, Qmake_symbolic_link, target, - linkname, ok_if_already_exists); - /* If the new link name has special constructs in it, call the corresponding file handler. */ handler =3D Ffind_file_name_handler (linkname, Qmake_symbolic_link); @@ -2635,11 +2630,6 @@ emacs_readlinkat (int fd, char const *filename) return Qnil; =20 val =3D build_unibyte_string (buf); - if (buf[0] =3D=3D '/' && strchr (buf, ':')) - { - AUTO_STRING (slash_colon, "/:"); - val =3D concat2 (slash_colon, val); - } if (buf !=3D readlink_buf) xfree (buf); val =3D DECODE_FILE (val); diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 55f4b52..99a21f3 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2590,13 +2590,16 @@ tramp--test-backtrace (should-error (make-symbolic-link tmp-name1 tmp-name2)) (make-symbolic-link tmp-name1 tmp-name2 'ok-if-already-exists) (should (file-symlink-p tmp-name2)) - ;; `tmp-name3' is a local file name. - (should-error (make-symbolic-link tmp-name1 tmp-name3))) + ;; `tmp-name3' is a local file name, so its target is not + ;; interpreted. + (make-symbolic-link tmp-name1 tmp-name3) + (should (equal tmp-name1 (file-symlink-p tmp-name3)))) =20 ;; Cleanup. (ignore-errors (delete-file tmp-name1) - (delete-file tmp-name2))) + (delete-file tmp-name2) + (delete-file tmp-name3))) =20 ;; Check `add-name-to-file'. (unwind-protect diff --git a/test/src/fileio-tests.el b/test/src/fileio-tests.el index 2ef1b55..5103d2f 100644 --- a/test/src/fileio-tests.el +++ b/test/src/fileio-tests.el @@ -19,14 +19,13 @@ =20 (require 'ert) =20 -(defun try-char (char link) - (let ((target (string char))) - (make-symbolic-link target link) - (let* ((read-link (file-symlink-p link)) - (failure (unless (string-equal target read-link) - (list 'string-equal target read-link)))) - (delete-file link) - failure))) +(defun try-link (target link) + (make-symbolic-link target link) + (let* ((read-link (file-symlink-p link)) + (failure (unless (string-equal target read-link) + (list 'string-equal target read-link)))) + (delete-file link) + failure)) =20 (defun fileio-tests--symlink-failure () (let* ((dir (make-temp-file "fileio" t)) @@ -36,9 +35,9 @@ fileio-tests--symlink-failure (char 0)) (while (and (not failure) (< char 127)) (setq char (1+ char)) - (unless (=3D char ?~) - (setq failure (try-char char link)))) - failure) + (setq failure (try-link (string char) link))) + (or failure + (try-link "/:" link))) (delete-directory dir t)))) =20 (ert-deftest fileio-tests--odd-symlink-chars () --=20 2.7.4 --------------98856F137A45DD1AD208EE77-- From debbugs-submit-bounces@debbugs.gnu.org Fri Aug 25 08:46:15 2017 Received: (at 28156) by debbugs.gnu.org; 25 Aug 2017 12:46:15 +0000 Received: from localhost ([127.0.0.1]:53799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlE07-0008TT-3f for submit@debbugs.gnu.org; Fri, 25 Aug 2017 08:46:15 -0400 Received: from mout.gmx.net ([212.227.15.18]:51174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlE04-0008TG-SA for 28156@debbugs.gnu.org; Fri, 25 Aug 2017 08:46:13 -0400 Received: from detlef.gmx.de ([213.220.151.125]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M1Fe4-1dW1Yw1sb2-00tDxo; Fri, 25 Aug 2017 14:45:54 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> <87tw10qcwz.fsf@detlef> <787f2dca-7135-3da5-4516-99d12ecf8edd@cs.ucla.edu> <87a82p8abu.fsf@detlef> <732853c9-87db-e108-edb9-cf581fc62e67@cs.ucla.edu> Date: Fri, 25 Aug 2017 14:45:49 +0200 In-Reply-To: <732853c9-87db-e108-edb9-cf581fc62e67@cs.ucla.edu> (Paul Eggert's message of "Thu, 24 Aug 2017 22:12:28 -0700") Message-ID: <87h8wvlssi.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:LInoPc0rUAOogTdO0kbb/5v7dODCzPSfZweNS17if0l7hGOkYLO W2CJBf5y6cZIOxcmR36Ypvql4nkBzbWjkZ2ZA+1rSE6zTjnEA+T+OtzZk0Apa1sMx8W5S0Q jJTAhNLVh84qvh3Ra7rgsfw1Yo40tykSMuZwkRPUiePxfD0SvVlanvUDzGWoPTtgFRdy/YH 2nRiPOxdTjICmDMKKzEiA== X-UI-Out-Filterresults: notjunk:1;V01:K0:gO9BSm7BdXo=:YRU2j00g2Y6Hk9KNUzBmjc qoQfwetVt4uN2dinyg+d2PjiQ+GJ19avdMxAWf4naRzraPF1N57Yhvka09adcAFlG2jll8Ccf cU6kdYNFVCVRc04fQd0bcjmQLMWjLmwncPJWATXT9bht1+8/i+7V1ci3ciV4fcEVSbo/9fO7t KI9dqIuctLHhsHqRPZ3Cziub0u7t87RLyVbXkoo37/uDHqdsUH/SzWNd6Uvz5ZU82YKkh6/xt GHcD0iVwWmR8XCOYNsQQPC6CAWSkwlAE/aKGehzvKNb0Ytyt+AbIJ92NTMLa37N1UCsqwFduB WrVF8VtCpLRw7EhXsunvcQTjyuuMCue1Rsub3SLlw0+JGg8B3lo0TpuBZDJEBTEj4LUKbqXzA CMrpImogTWBMg7vQdPYlsKQ/FMhL/s+zsNi/AfP/2m7ZzorMVtx+zzsI4mqgIu/iq1LFoy0g3 0BflEB1rJnxbcsd3niUK9h0sZu0QcRgwVllPJkUrBBFOdlyJ24UzCZCwWDsHFXKEuzMnKnt/S prrzhdtj+Ak4At06pF9AQmwbpNLCrX6cukPnvj9nxqiBoVBhxVnERL0tzXvf9p5I9JeVbNo7t AVWYyIk3C/vJE+3ixcp1cb1c5qLi8VlElOAHj1QPRycP2hpk7uKLrq/j37Y46SHxUMv9ce8EA FDUS/TvaBgXEpLNXw7qX6q5N8nbMRJwR9M06cw0+AZSaNWafcfh+f4jKzDYar5fQdy53nTK5h lNDNCXJjKsWw/c4qA1CYKoOHRqWoChY1NC/H0xFMoIsYcHmcmaj2JU3G3Ae6h0UrXLLakzKey U1OaorThnvc3C7/xrGBunGZUhr0q6rJ6mWVOaXX8RyH80TaAT4= X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , p.stephani2@gmail.com, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) Paul Eggert writes: Hi Paul, >> For a TARGET which looks like a remote file name, I propose to keep the >> current behaviour (stripping the remote part). > > That's fine if LINKNAME is also remote, since symlinks act > locally. That is, if TARGET and LINKNAME are both remote to the same > filesystem, Tramp can continue to munge TARGET so that it works on > that filesystem. However, Tramp should not be in the business of > specifying symlink behavior for local symbolic links. It should let > the OS do that. If LINKNAME is local, TARGET should just act as itself > without Tramp getting in the way. Tramp checks already in this case, that LINKNAME and TARGET belong to the same remote filesystem. I just need to add the case, that TARGET is used literally otherwise. > diff --git a/etc/NEWS b/etc/NEWS > index bf59749..60ddf54 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -1228,6 +1228,30 @@ instead of to utf-8. Before this change, Emacs would sometimes > mishandle file names containing these control characters. > > +++ > +** 'file-attributes', 'file-symlink-p' and 'make-symbolic-link' no > +longer quietly mutate the target of a local symbolic link, so that > +Emacs can access and copy them reliably regardless of their contents. > +The following changes are involved. > + > +*** 'file-attributes' and 'file-symlink-p' no longer prepend "/:" to > +symbolic links whose targets begin with "/" and contain ":". For > +example, if a symbolic link "x" has a target "/y:z", (file-symlink-p > +"x") now returns "/y:z" rather than "/:/y:z". What about file-truename? I believe it still must quote the result, otherwise we run into problems. See (make-symbolic-link "/x:y:" "/tmp/foo") (file-truename "/tmp/foo") The latter shall return "/:/x:y:" (as of today) instead of "/x:y:". Otherwise, we would allow symbolic links over filesystem borders inside Emacs, which would be a security problem. Maybe we shall document it as well. Neither the docstring of `file-truename', nor the Lisp reference say something about. > diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el > index 55f4b52..99a21f3 100644 > --- a/test/lisp/net/tramp-tests.el > +++ b/test/lisp/net/tramp-tests.el You don't need to do this, I'll care for Tramp. Likely, I will add further tests here. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 26 09:16:37 2017 Received: (at 28156) by debbugs.gnu.org; 26 Aug 2017 13:16:37 +0000 Received: from localhost ([127.0.0.1]:56153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlax2-00047L-UO for submit@debbugs.gnu.org; Sat, 26 Aug 2017 09:16:37 -0400 Received: from mout.gmx.net ([212.227.17.21]:57550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlax0-000477-Ry for 28156@debbugs.gnu.org; Sat, 26 Aug 2017 09:16:35 -0400 Received: from detlef.gmx.de ([79.140.112.117]) by mail.gmx.com (mrgmx103 [212.227.17.168]) with ESMTPSA (Nemesis) id 0MLvLE-1dtHWW1yc0-007ovx; Sat, 26 Aug 2017 15:16:16 +0200 From: Michael Albinus To: Paul Eggert Subject: Re: bug#28156: Emacs quietly munges symlink contents References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> <87tw10qcwz.fsf@detlef> <787f2dca-7135-3da5-4516-99d12ecf8edd@cs.ucla.edu> <87a82p8abu.fsf@detlef> <732853c9-87db-e108-edb9-cf581fc62e67@cs.ucla.edu> <87h8wvlssi.fsf@detlef> Date: Sat, 26 Aug 2017 15:16:13 +0200 In-Reply-To: <87h8wvlssi.fsf@detlef> (Michael Albinus's message of "Fri, 25 Aug 2017 14:45:49 +0200") Message-ID: <87valaeag2.fsf@detlef> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K0:/dTiqHa4O7J/vYZmkv+X/EFENtElGG/x27npdy/mR91x1Ez1c2Z fJZMbai8ZTzdzXDIxeNoRdIz/m+ICIqQua5URXpWvqLDY+vQnwJzQkwQu5wD5Ml7iRsRmLf rMIvCo2c7Zz4lRRGaK5Va3w9aZT8PLEyo8SFURibLD4aumRPRG1Lm9bBz4ndUOISdTV25fE Dk5Z5lmz2CY/N6FjUdgZA== X-UI-Out-Filterresults: notjunk:1;V01:K0:EdDVcomW9mM=:bQV1Z6pbC6sZHpeLa7qDyK FaVqj5MwxbS4FnYJ+dTQthA/0b4zpZ9WS/+Wq+yzVTmY1f8ZsnPai06fze94Wn/SI9eMIsmJS 3BwqC3iYo7w5X0veWkPKutzt+s6rG1n2qoOUX2dZ7y3eZ+CUU3lPOrDobTTNhGUHkZMbio823 tfNvj8IL4pR7kMpLpiv3v/lZf+lcKAiWEbLdNv0+MWvbCt8ql4U8nZ2epjfJmgRrFKTBtuoqq /xetY5L9M1GDKHyWa/kQhyUnQ62L03E/dbLmSS0FFZI0vwF5P5qhCtxGLecShJQs2dV2L4nzL aq2NNNVyd+maKSTGTgTCkvNZjsj6zrmqjlLi4EZsG0D2gAv+8oTfnNuQjaPOu0gVpKQXyMc74 /qA44E9albCrYxMH22VgkHWKTCuCf/9vvUsEmpRkqAEIqnN7yA7kZqoMesQ2naR/FrT0qpyHB 9KxC7ywYDyLp3R1ooF+6Ca1WwwAuNvX2EFtlA7Qebg0PjJhgVDua3wrOlZ/b73L1fHIwMPKU1 09vL4xTf9kZVgxwf6DNh5KEaBef4GvNkzG2w6vsLnH22dBx1gz3ovI4JSYkAdRAiR9L5f8rK8 42F7/s7HSCIXIvHD8U5ujZj2kV5oTmVmnXJHn/+9SAu+HrpqiLYOgkg2zHsthosDKxEwHr85H +cvMemQjHiRlvb2tsqZ5gnGZYOLMM1t2KD+MPNOH7twqiL761ezyiC6Og8UrIfdyw3YlqHbGg xZiq+9gS62tmctgpTMpRzZYCKtiGdlDm64kKFkw5uXM826kLgMFngc9H5U0eZQZwfO/xFqyk9 XtfeMHuWpIB4Wi0UVURCBXCX91z1ydy8oTXggyI15Qi0F3dpWk= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 28156 Cc: Eli Zaretskii , p.stephani2@gmail.com, 28156@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) Michael Albinus writes: Hi Paul, >> That's fine if LINKNAME is also remote, since symlinks act >> locally. That is, if TARGET and LINKNAME are both remote to the same >> filesystem, Tramp can continue to munge TARGET so that it works on >> that filesystem. However, Tramp should not be in the business of >> specifying symlink behavior for local symbolic links. It should let >> the OS do that. If LINKNAME is local, TARGET should just act as itself >> without Tramp getting in the way. > > Tramp checks already in this case, that LINKNAME and TARGET belong to > the same remote filesystem. I just need to add the case, that TARGET is > used literally otherwise. I've commited a patch to the repo which does it for Tramp. Well, there are still some minor oddities when testing with the smb method, will fix this the next days. >> diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el >> index 55f4b52..99a21f3 100644 >> --- a/test/lisp/net/tramp-tests.el >> +++ b/test/lisp/net/tramp-tests.el > > You don't need to do this, I'll care for Tramp. Likely, I will add > further tests here. Done also. Best regards, Michael. From debbugs-submit-bounces@debbugs.gnu.org Sat Aug 26 21:53:45 2017 Received: (at 28156-done) by debbugs.gnu.org; 27 Aug 2017 01:53:45 +0000 Received: from localhost ([127.0.0.1]:56931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlmll-0004pf-49 for submit@debbugs.gnu.org; Sat, 26 Aug 2017 21:53:45 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:60314) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlmlh-0004pR-Sg for 28156-done@debbugs.gnu.org; Sat, 26 Aug 2017 21:53:43 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1A37C160872; Sat, 26 Aug 2017 18:53:35 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id K2oOxmH-HXWa; Sat, 26 Aug 2017 18:53:34 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 5848D160891; Sat, 26 Aug 2017 18:53:34 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id W42V9H1Iep2D; Sat, 26 Aug 2017 18:53:34 -0700 (PDT) Received: from [192.168.1.9] (unknown [47.153.184.153]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 30425160865; Sat, 26 Aug 2017 18:53:34 -0700 (PDT) Subject: Re: bug#28156: Emacs quietly munges symlink contents To: Michael Albinus References: <68b2e6ef-bf0b-ebcf-c577-d296952d593f@cs.ucla.edu> <83pobqcnlf.fsf@gnu.org> <83h8x2ckqn.fsf@gnu.org> <83bmnacaob.fsf@gnu.org> <1fafa4ea-424e-53c5-3c91-6dd18fe47f1e@cs.ucla.edu> <83bmn8by40.fsf@gnu.org> <5963ac31-06cc-7784-bf21-46b76bd77c51@cs.ucla.edu> <87tw10qcwz.fsf@detlef> <787f2dca-7135-3da5-4516-99d12ecf8edd@cs.ucla.edu> <87a82p8abu.fsf@detlef> <732853c9-87db-e108-edb9-cf581fc62e67@cs.ucla.edu> <87h8wvlssi.fsf@detlef> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sat, 26 Aug 2017 18:53:25 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <87h8wvlssi.fsf@detlef> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 28156-done Cc: Eli Zaretskii , p.stephani2@gmail.com, 28156-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Michael Albinus wrote: > What about file-truename? I believe it still must quote the result, > otherwise we run into problems. See >=20 > (make-symbolic-link "/x:y:" "/tmp/foo") > (file-truename "/tmp/foo") >=20 > The latter shall return "/:/x:y:" (as of today) instead of > "/x:y:". Thanks for catching that. While looking into it, I noticed that file-true= name=20 has long mishandled symlink contents starting with ~ as in the following = example: $ ln -s '~nosuchuser' /tmp/foo $ ls -l /tmp/foo lrwxrwxrwx. 1 eggert eggert 11 Aug 26 18:51 /tmp/foo -> ~nosuchuser $ src/emacs -Q -batch -eval '(message "%S" (file-truename "/tmp/foo"))' "/home/eggert/src/gnu/emacs/master-tmp/~nosuchuser" I fixed both problems. > Maybe we shall document it as well. Neither the docstring of > `file-truename', nor the Lisp reference say something about. Yes, the documentation could stand some improving here. I fixed it up a b= it,=20 though not in the file-truename area as I'm thinking we may need some mor= e=20 changes here and would like to cogitate about it first. I'll CC: you on a= ny=20 further bug reports in this area. I rebased the patch to master which simplified it since I no longer had t= o worry=20 about Tramp tests, and installed the result. Closing this bug report. From unknown Thu Jun 19 14:03:13 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 24 Sep 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator