[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tramp (2.2.12); Retrieve of links attributes with stat fail when lin
From: |
Pierre Téchoueyres |
Subject: |
Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes. |
Date: |
Thu, 20 Aug 2015 23:44:19 +0200 |
User-agent: |
KMail/4.14.9 (Linux/4.1.4-200.fc22.x86_64; KDE/4.14.9; x86_64; ; ) |
Hi Michael,
>
> Well, this is too much hassle I fear. We DON'T know which shells, and
> which broken implementations of them, are used remotely. So I rather
> oppose such a patch.
>
> What do you think about my other proposal, using `tramp-end-of-heredoc'
> as marker?
>
So patch is at end of this e-mail. But as guessed the shell generated command
is really *ugly*. See attached file.
The shell generated command for
`tramp-do-directory-files-and-attributes-with-stat' look as the previous.
I ran make check with
"REMOTE_TEMPORARY_FILE_DIRECTORY=/sshx:address@hidden:tmp" :
> Ran 42 tests, 42 results as expected (2015-08-20 23:23:23+0200)
> 2 expected failures
This seem's OK. But I haven't found my way to add a test for link with double
slash in path or for file like '*dummy with "spaces"*'.
Best regards, Pierre
--8<---------------cut here---------------start------------->8---
1 file changed, 43 insertions(+), 39 deletions(-)
lisp/tramp-sh.el | 82 +++++++++++++++++++++++++++++---------------------------
modified lisp/tramp-sh.el
@@ -1295,28 +1295,30 @@ target of the symlink differ."
(tramp-shell-quote-argument localname) id-format)))
(defun tramp-do-file-attributes-with-stat
- (vec localname &optional id-format)
+ (vec localname &optional id-format)
"Implement `file-attributes' for Tramp files using stat(1) command."
(tramp-message vec 5 "file attributes with stat: %s" localname)
(tramp-send-command-and-read
vec
- (format
- (concat
- ;; On Opsware, pdksh (which is the true name of ksh there)
- ;; doesn't parse correctly the sequence "((". Therefore, we add
- ;; a space. Apostrophes in the stat output are masked as "//",
- ;; in order to make a proper shell escape of them in file names.
- "( (%s %s || %s -h %s) && (%s -c "
- "'((//%%N//) %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 //%%A// t %%ie0 -1)' "
- "%s | sed -e 's/\"/\\\\\"/g' -e 's/\\/\\//\"/g') || echo nil)")
- (tramp-get-file-exists-command vec)
- (tramp-shell-quote-argument localname)
- (tramp-get-test-command vec)
- (tramp-shell-quote-argument localname)
- (tramp-get-remote-stat vec)
- (if (eq id-format 'integer) "%ue0" "//%U//")
- (if (eq id-format 'integer) "%ge0" "//%G//")
- (tramp-shell-quote-argument localname))))
+ (replace-regexp-in-string
+ "\\\\0" tramp-end-of-heredoc
+ (format
+ (concat
+ ;; On Opsware, pdksh (which is the true name of ksh there)
+ ;; doesn't parse correctly the sequence "((". Therefore, we add
+ ;; a space. Apostrophes in the stat output are masked as
`tramp-end-of-heredoc',
+ ;; in order to make a proper shell escape of them in file names.
+ "( (%s %s || %s -h %s) && (%s -c "
+ "'((\\0%%N\\0) %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 \\0%%A\\0 t %%ie0 -1)' "
+ "%s | sed -e 's/\"/\\\\\"/g' -e 's/\\0/\"/g') || echo nil)")
+ (tramp-get-file-exists-command vec)
+ (tramp-shell-quote-argument localname)
+ (tramp-get-test-command vec)
+ (tramp-shell-quote-argument localname)
+ (tramp-get-remote-stat vec)
+ (if (eq id-format 'integer) "%ue0" "\\0%U\\0")
+ (if (eq id-format 'integer) "%ge0" "\\0%G\\0")
+ (tramp-shell-quote-argument localname)))))
(defun tramp-sh-handle-set-visited-file-modtime (&optional time-list)
"Like `set-visited-file-modtime' for Tramp files."
@@ -1737,31 +1739,33 @@ be non-negative integers."
object))
(defun tramp-do-directory-files-and-attributes-with-stat
- (vec localname &optional id-format)
+ (vec localname &optional id-format)
"Implement `directory-files-and-attributes' for Tramp files using stat(1)
command."
(tramp-message vec 5 "directory-files-and-attributes with stat: %s"
localname)
(tramp-send-command-and-read
vec
- (format
- (concat
- ;; We must care about file names with spaces, or starting with
- ;; "-"; this would confuse xargs. "ls -aQ" might be a solution,
- ;; but it does not work on all remote systems. Apostrophes in
- ;; the stat output are masked as "//", in order to make a proper
- ;; shell escape of them in file names.
- "cd %s && echo \"(\"; (%s %s -a | "
- "xargs %s -c "
- "'(//%%n// (//%%N//) %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 //%%A// t %%ie0
-1)' "
- "-- 2>/dev/null | sed -e 's/\"/\\\\\"/g' -e 's/\\/\\//\"/g'); echo \")\"")
- (tramp-shell-quote-argument localname)
- (tramp-get-ls-command vec)
- ;; On systems which have no quoting style, file names with
- ;; special characters could fail.
- (if (tramp-get-ls-command-with-quoting-style vec)
- "--quoting-style=shell" "")
- (tramp-get-remote-stat vec)
- (if (eq id-format 'integer) "%ue0" "//%U//")
- (if (eq id-format 'integer) "%ge0" "//%G//"))))
+ (replace-regexp-in-string
+ "\\\\0" tramp-end-of-heredoc
+ (format
+ (concat
+ ;; We must care about file names with spaces, or starting with
+ ;; "-"; this would confuse xargs. "ls -aQ" might be a solution,
+ ;; but it does not work on all remote systems. Apostrophes in
+ ;; the stat output are masked as `tramp-end-of-heredoc', in order to
make a proper
+ ;; shell escape of them in file names.
+ "cd %s && echo \"(\"; (%s %s -a | "
+ "xargs %s -c "
+ "'(\\0%%n\\0 (\\0%%N\\0) %%h %s %s %%Xe0 %%Ye0 %%Ze0 %%se0 \\0%%A\\0 t
%%ie0 -1)' "
+ "-- 2>/dev/null | sed -e 's/\"/\\\\\"/g' -e 's/\\0/\"/g'); echo \")\"")
+ (tramp-shell-quote-argument localname)
+ (tramp-get-ls-command vec)
+ ;; On systems which have no quoting style, file names with
+ ;; special characters could fail.
+ (if (tramp-get-ls-command-with-quoting-style vec)
+ "--quoting-style=shell" "")
+ (tramp-get-remote-stat vec)
+ (if (eq id-format 'integer) "%ue0" "\\0%U\\0")
+ (if (eq id-format 'integer) "%ge0" "\\0%G\\0")))))
;; This function should return "foo/" for directories and "bar" for
;; files.
--8<---------------cut here---------------end--------------->8---
scpx ptechoueyres@localhost*
Description: Text document
- tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Pierre Téchoueyres, 2015/08/19
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Michael Albinus, 2015/08/20
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., yary, 2015/08/20
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Michael Albinus, 2015/08/20
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Pierre Téchoueyres, 2015/08/20
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Michael Albinus, 2015/08/20
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Pierre Téchoueyres, 2015/08/20
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Michael Albinus, 2015/08/21
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes.,
Pierre Téchoueyres <=
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Michael Albinus, 2015/08/21
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Michael Albinus, 2015/08/24
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., pierre . techoueyres, 2015/08/24
- Re: tramp (2.2.12); Retrieve of links attributes with stat fail when link contains two slashes., Michael Albinus, 2015/08/24