diff options
| author | Paul Eggert | 2017-08-26 18:36:38 -0700 |
|---|---|---|
| committer | Paul Eggert | 2017-08-26 18:36:38 -0700 |
| commit | e8001d4c27e1e33c83b9994aac4d5fc3feada2da (patch) | |
| tree | 6910256d7cf7723aa1b3f7ab7779b91627ba52f6 /doc | |
| parent | 937d9d7f60460edb1d3f978151599fddcbba2214 (diff) | |
| download | emacs-e8001d4c27e1e33c83b9994aac4d5fc3feada2da.tar.gz emacs-e8001d4c27e1e33c83b9994aac4d5fc3feada2da.zip | |
Do not munge contents of local symbolic links
This lets Emacs deal with arbitrary local symlinks without
mishandling their contents (Bug#28156). 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.
* lisp/dired.el (dired-get-filename): Use files--name-absolute-system-p
instead of rolling our own code.
* lisp/files.el (files--name-absolute-system-p): New function.
(file-truename, file-chase-links): Use it to avoid mishandling
symlink contents that begin with ~.
(copy-directory, move-file-to-trash):
Use concat rather than expand-file-name, to avoid mishandling
symlink contents that begin with ~.
* src/fileio.c (Fmake_symbolic_link): Do not expand leading "~" in the
target unless interactive. Strip leading "/:" if interactive.
(emacs_readlinkat): Do not prepend "/:" to the link target if
it starts with "/" and contains ":" before NUL.
* 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.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/emacs/files.texi | 8 | ||||
| -rw-r--r-- | doc/lispref/files.texi | 11 |
2 files changed, 13 insertions, 6 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi index 9195bc47efe..fa1f9e53165 100644 --- a/doc/emacs/files.texi +++ b/doc/emacs/files.texi | |||
| @@ -1611,8 +1611,12 @@ attempts to open file @var{new} will refer to whatever file is named | |||
| 1611 | @var{target} at the time the opening is done, or will get an error if | 1611 | @var{target} at the time the opening is done, or will get an error if |
| 1612 | the name @var{target} is nonexistent at that time. This command does | 1612 | the name @var{target} is nonexistent at that time. This command does |
| 1613 | not expand the argument @var{target}, so that it allows you to specify | 1613 | not expand the argument @var{target}, so that it allows you to specify |
| 1614 | a relative name as the target of the link. On MS-Windows, this | 1614 | a relative name as the target of the link. However, this command |
| 1615 | command works only on MS Windows Vista and later. On remote systems, | 1615 | does expand leading @samp{~} in @var{target} so that you can easily |
| 1616 | specify home directories, and strips leading @samp{/:} so that you can | ||
| 1617 | specify relative names beginning with literal @samp{~} or @samp{/:}. | ||
| 1618 | @xref{Quoted File Names}. On MS-Windows, this command works only on | ||
| 1619 | MS Windows Vista and later. When @var{new} is remote, | ||
| 1616 | it works depending on the system type. | 1620 | it works depending on the system type. |
| 1617 | 1621 | ||
| 1618 | @node Misc File Ops | 1622 | @node Misc File Ops |
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi index f701d683703..06466c9bba8 100644 --- a/doc/lispref/files.texi +++ b/doc/lispref/files.texi | |||
| @@ -1726,14 +1726,17 @@ default file permissions (see @code{set-default-file-modes} below), if | |||
| 1726 | SELinux context are not copied over in either case. | 1726 | SELinux context are not copied over in either case. |
| 1727 | @end deffn | 1727 | @end deffn |
| 1728 | 1728 | ||
| 1729 | @deffn Command make-symbolic-link filename newname &optional ok-if-already-exists | 1729 | @deffn Command make-symbolic-link target newname &optional ok-if-already-exists |
| 1730 | @pindex ln | 1730 | @pindex ln |
| 1731 | @kindex file-already-exists | 1731 | @kindex file-already-exists |
| 1732 | This command makes a symbolic link to @var{filename}, named | 1732 | This command makes a symbolic link to @var{target}, named |
| 1733 | @var{newname}. This is like the shell command @samp{ln -s | 1733 | @var{newname}. This is like the shell command @samp{ln -s |
| 1734 | @var{filename} @var{newname}}. The @var{filename} argument | 1734 | @var{target} @var{newname}}. The @var{target} argument |
| 1735 | is treated only as a string; it need not name an existing file. | 1735 | is treated only as a string; it need not name an existing file. |
| 1736 | If @var{filename} is a relative file name, the resulting symbolic link | 1736 | If @var{ok-if-already-exists} is an integer, indicating interactive |
| 1737 | use, then leading @samp{~} is expanded and leading @samp{/:} is | ||
| 1738 | stripped in the @var{target} string. | ||
| 1739 | If @var{target} is a relative file name, the resulting symbolic link | ||
| 1737 | is interpreted relative to the directory containing the symbolic link. | 1740 | is interpreted relative to the directory containing the symbolic link. |
| 1738 | @xref{Relative File Names}. | 1741 | @xref{Relative File Names}. |
| 1739 | 1742 | ||