* bug#17238: 24.3; TRAMP Can't open remote file with '$' in the filename
@ 2014-04-11 3:01 Dana Pieluszczak
2014-04-11 6:36 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Dana Pieluszczak @ 2014-04-11 3:01 UTC (permalink / raw
To: 17238
[-- Attachment #1.1: Type: text/plain, Size: 4608 bytes --]
Preconditions
- A linux host which you have ssh access to (192.168.1.105 in the example
below)
- An account on said host
- SHELL on the remote host is /bin/bash (GNU bash, version
4.2.25(1)-release (i686-pc-linux-gnu)
Reproduction steps
$ ssh dana@192.168.1.105 'echo "some content" > /home/dana/t\$test.txt'
# verify there's some content in the file
$ ssh dana@192.168.1.105 'cat /home/dana/t\$test.txt'
$ emacs -Q -nw
# now we're in emacs
C-x C-f DEL DEL /dana@192.168.1.105:/home/dana/t$test.txt RET
Expected result
- a new buffer called t$test.txt is opened visiting the remote file
Actual result
- a new buffer called t$test.txt is opened
- the buffer is empty
- The following is written to *Messages* buffer:
File exists, but cannot be read
This is a bug in tramp-sh-handle-file-truename. I've attached a
patch. The current version of tramp-sh-handle-file-truename uses
backticks inside a quoted string. Shell arguments used inside the
backticks should be shell escaped twice, but they're not.
I've changed the shell command to use a subshell ( $(...) )
Instead of backticks which removes the need for the double escaping.
I've done my best to follow the guidelines for reporting a bug and
submitting a patch. I'll be happy to fix up whatever is necessary to get
this accepted.
Dana P
If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
`bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
/Applications/Emacs.app/Contents/Resources/etc/DEBUG.
In GNU Emacs 24.3.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
of 2013-03-13 on bob.porkrind.org
Windowing system distributor `Apple', version 10.3.1265
Configured using:
`configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin'
'--with-ns' 'build_alias=i686-apple-darwin'
'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.7
-isystem
/Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include/
-F/Users/david/Xcode-10.7_4.5.2/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks''
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: Text
Minor modes in effect:
shell-dirtrack-mode: t
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
buffer-read-only: t
line-number-mode: t
transient-mark-mode: t
Recent input:
ESC [ ? 1 ; 2 c C-x C-f DEL DEL / d a n a @ 1 9 2 .
1 6 8 . 1 . 1 0 1 DEL 5 : t DEL / h o m e / d a n a
/ t $ t e s t . t x t RET ESC x r e p o r t TAB RE
T
Recent messages:
Tramp: Opening connection for dana@192.168.1.105 using scpc...done
Tramp: Inserting `/scpc:dana@192.168.1.105:/home/dana/t$test.txt'...done
File exists, but cannot be read
Tramp: Checking `vc-registered' for /scpc:dana@192.168.1.105:
/home/dana/t$test.txt...done
File exists, but cannot be read
Tramp: Checking `vc-registered' for /scpc:dana@192.168.1.105:
/home/dana/t.txt...done
File exists, but cannot be read
current-kill: Kill ring is empty
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message rfc822 mml easymenu mml-sec
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mail-utils tramp-cache
tramp-sh tramp tramp-compat auth-source eieio byte-opt bytecomp
byte-compile cconv gnus-util mm-util mail-prsvr password-cache
tramp-loaddefs shell pcomplete comint ansi-color ring format-spec advice
help-fns cl-lib advice-preload time-date tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax
facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
make-network-process ns multi-tty emacs)
[-- Attachment #1.2: Type: text/html, Size: 10412 bytes --]
[-- Attachment #2: fix-tramp-dollar-filename.patch --]
[-- Type: application/octet-stream, Size: 471 bytes --]
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 22ea771..ca1af88 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -954,7 +954,7 @@ target of the symlink differ."
(setq result
(tramp-send-command-and-read
v
- (format "echo \"\\\"`%s --canonicalize-missing %s`\\\"\""
+ (format "echo \"\\\"$(%s --canonicalize-missing %s)\\\"\""
(tramp-get-remote-readlink v)
(tramp-shell-quote-argument localname)))))
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#17238: 24.3; TRAMP Can't open remote file with '$' in the filename
2014-04-11 3:01 bug#17238: 24.3; TRAMP Can't open remote file with '$' in the filename Dana Pieluszczak
@ 2014-04-11 6:36 ` Michael Albinus
2014-04-11 12:32 ` Dana Pieluszczak
0 siblings, 1 reply; 4+ messages in thread
From: Michael Albinus @ 2014-04-11 6:36 UTC (permalink / raw
To: Dana Pieluszczak; +Cc: 17238
Dana Pieluszczak <danajp@gmail.com> writes:
Hi Dana,
> # now we're in emacs
> C-x C-f DEL DEL /dana@192.168.1.105:/home/dana/t$test.txt RET
For the records, it should be "/dana@192.168.1.105:/home/dana/t$$test.txt".
It works for you because "$test" is not an environment variable;
otherwise it would be replaced.
> Actual result
>
> - a new buffer called t$test.txt is opened
> - the buffer is empty
> - The following is written to *Messages* buffer:
> File exists, but cannot be read
Confirmed, I could reproduce it.
> This is a bug in tramp-sh-handle-file-truename. I've attached a
> patch. The current version of tramp-sh-handle-file-truename uses
> backticks inside a quoted string. Shell arguments used inside the
> backticks should be shell escaped twice, but they're not.
>
> I've changed the shell command to use a subshell ( $(...) )
> Instead of backticks which removes the need for the double escaping.
We cannot use the $(...) syntax, because we don't know whether the
remote shell does support it. Instead, we shall quote the file name twice.
Does the following patch work for you? (The line numbers might differ)
--8<---------------cut here---------------start------------->8---
*** /usr/share/emacs/24.3/lisp/net/tramp-sh.el.~1~ 2014-04-11 08:19:48.434437606 +0200
--- /usr/share/emacs/24.3/lisp/net/tramp-sh.el 2014-04-11 08:19:48.594440377 +0200
***************
*** 1066,1072 ****
v
(format "echo \"\\\"`%s --canonicalize-missing %s`\\\"\""
(tramp-get-remote-readlink v)
! (tramp-shell-quote-argument localname)))))
;; Use Perl implementation.
((and (tramp-get-remote-perl v)
--- 1066,1073 ----
v
(format "echo \"\\\"`%s --canonicalize-missing %s`\\\"\""
(tramp-get-remote-readlink v)
! (tramp-shell-quote-argument
! (tramp-shell-quote-argument localname))))))
;; Use Perl implementation.
((and (tramp-get-remote-perl v)
--8<---------------cut here---------------end--------------->8---
> Dana P
Best regards, Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#17238: 24.3; TRAMP Can't open remote file with '$' in the filename
2014-04-11 6:36 ` Michael Albinus
@ 2014-04-11 12:32 ` Dana Pieluszczak
2014-04-11 13:02 ` Michael Albinus
0 siblings, 1 reply; 4+ messages in thread
From: Dana Pieluszczak @ 2014-04-11 12:32 UTC (permalink / raw
To: Michael Albinus; +Cc: 17238
Michael,
> We cannot use the $(...) syntax, because we don't know whether the
> remote shell does support it. Instead, we shall quote the file name twice.
I figured that might be the reason for the backticks.
> Does the following patch work for you? (The line numbers might differ)
Yes, works for me.
Thanks,
Dana P
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#17238: 24.3; TRAMP Can't open remote file with '$' in the filename
2014-04-11 12:32 ` Dana Pieluszczak
@ 2014-04-11 13:02 ` Michael Albinus
0 siblings, 0 replies; 4+ messages in thread
From: Michael Albinus @ 2014-04-11 13:02 UTC (permalink / raw
To: Dana Pieluszczak; +Cc: 17238-done
Version: 24.4
Dana Pieluszczak <danajp@gmail.com> writes:
> Michael,
Hi Dana,
>> Does the following patch work for you? (The line numbers might differ)
>
> Yes, works for me.
Thanks for confirmation. I've committed the patch in the emacs-24
branch, it will appear with Emacs 24.4. Closing the bug.
> Thanks,
>
> Dana P
Best regards, Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-11 13:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11 3:01 bug#17238: 24.3; TRAMP Can't open remote file with '$' in the filename Dana Pieluszczak
2014-04-11 6:36 ` Michael Albinus
2014-04-11 12:32 ` Dana Pieluszczak
2014-04-11 13:02 ` Michael Albinus
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).