aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2015-12-06 18:55:50 +0100
committerMichael Albinus2015-12-06 18:55:50 +0100
commit0e574ea35ea75fa91a38718966ffe6c17b8e93d8 (patch)
treee0c14ac0d60f1d0e731b93cb4dd70249a1ef58b6
parentcca5629f7856d88de940da942acbf5ca7f95a944 (diff)
downloademacs-0e574ea35ea75fa91a38718966ffe6c17b8e93d8.tar.gz
emacs-0e574ea35ea75fa91a38718966ffe6c17b8e93d8.zip
Fix minor Tramp problems found on BSD
* lisp/net/tramp-sh.el (tramp-perl-file-truename): Do not append trailing slash. Quote apostrophes. (tramp-sh-handle-file-truename): Do not append trailing slash in the "ls" case. (tramp-get-ls-command-with-w-option): New defun. (tramp-do-file-attributes-with-ls) (tramp-do-directory-files-and-attributes-with-stat): Use it. * test/automated/tramp-tests.el (tramp-test31-special-characters-with-perl) (tramp-test31-special-characters-with-ls) (tramp-test32-utf8-with-perl, tramp-test32-utf8-with-ls): Suppress also readlink.
-rw-r--r--lisp/net/tramp-sh.el64
-rw-r--r--test/automated/tramp-tests.el20
2 files changed, 52 insertions, 32 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index a2153415f4d..2c2179e8285 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -621,10 +621,7 @@ if (!$result) {
621 $result = File::Spec->catpath($vol, File::Spec->catdir(@dirs), \"\"); 621 $result = File::Spec->catpath($vol, File::Spec->catdir(@dirs), \"\");
622} 622}
623 623
624if ($ARGV[0] =~ /\\/$/) { 624$result =~ s/\"/\\\\\"/g;
625 $result = $result . \"/\";
626}
627
628print \"\\\"$result\\\"\\n\"; 625print \"\\\"$result\\\"\\n\";
629' \"$1\" 2>/dev/null" 626' \"$1\" 2>/dev/null"
630 "Perl script to produce output suitable for use with `file-truename' 627 "Perl script to produce output suitable for use with `file-truename'
@@ -1143,20 +1140,17 @@ target of the symlink differ."
1143 1140
1144 ;; Do it yourself. We bind `directory-sep-char' here for 1141 ;; Do it yourself. We bind `directory-sep-char' here for
1145 ;; XEmacs on Windows, which would otherwise use backslash. 1142 ;; XEmacs on Windows, which would otherwise use backslash.
1146 (t (let* ((directory-sep-char ?/) 1143 (t (let ((directory-sep-char ?/)
1147 (steps (tramp-compat-split-string localname "/")) 1144 (steps (tramp-compat-split-string localname "/"))
1148 (localnamedir (tramp-run-real-handler 1145 (thisstep nil)
1149 'file-name-as-directory (list localname))) 1146 (numchase 0)
1150 (is-dir (string= localname localnamedir)) 1147 ;; Don't make the following value larger than
1151 (thisstep nil) 1148 ;; necessary. People expect an error message in a
1152 (numchase 0) 1149 ;; timely fashion when something is wrong;
1153 ;; Don't make the following value larger than 1150 ;; otherwise they might think that Emacs is hung.
1154 ;; necessary. People expect an error message in 1151 ;; Of course, correctness has to come first.
1155 ;; a timely fashion when something is wrong; 1152 (numchase-limit 20)
1156 ;; otherwise they might think that Emacs is hung. 1153 symlink-target)
1157 ;; Of course, correctness has to come first.
1158 (numchase-limit 20)
1159 symlink-target)
1160 (while (and steps (< numchase numchase-limit)) 1154 (while (and steps (< numchase numchase-limit))
1161 (setq thisstep (pop steps)) 1155 (setq thisstep (pop steps))
1162 (tramp-message 1156 (tramp-message
@@ -1212,10 +1206,8 @@ target of the symlink differ."
1212 (if result 1206 (if result
1213 (mapconcat 'identity (cons "" result) "/") 1207 (mapconcat 'identity (cons "" result) "/")
1214 "/")) 1208 "/"))
1215 (when (and is-dir 1209 (when (string= "" result)
1216 (or (string= "" result) 1210 (setq result "/")))))
1217 (not (string= (substring result -1) "/"))))
1218 (setq result (concat result "/"))))))
1219 1211
1220 (tramp-message v 4 "True name of `%s' is `%s'" localname result) 1212 (tramp-message v 4 "True name of `%s' is `%s'" localname result)
1221 result)))) 1213 result))))
@@ -1278,8 +1270,12 @@ target of the symlink differ."
1278 (tramp-get-ls-command vec) 1270 (tramp-get-ls-command vec)
1279 ;; On systems which have no quoting style, file names 1271 ;; On systems which have no quoting style, file names
1280 ;; with special characters could fail. 1272 ;; with special characters could fail.
1281 (if (tramp-get-ls-command-with-quoting-style vec) 1273 (cond
1282 "--quoting-style=c" "") 1274 ((tramp-get-ls-command-with-quoting-style vec)
1275 "--quoting-style=c")
1276 ((tramp-get-ls-command-with-w-option vec)
1277 "-w")
1278 (t ""))
1283 (if (eq id-format 'integer) "-ildn" "-ild") 1279 (if (eq id-format 'integer) "-ildn" "-ild")
1284 (tramp-shell-quote-argument localname))) 1280 (tramp-shell-quote-argument localname)))
1285 ;; Parse `ls -l' output ... 1281 ;; Parse `ls -l' output ...
@@ -1837,10 +1833,14 @@ be non-negative integers."
1837 "-- 2>/dev/null | sed -e 's/\"/\\\\\"/g' -e 's/%s/\"/g'); echo \")\"") 1833 "-- 2>/dev/null | sed -e 's/\"/\\\\\"/g' -e 's/%s/\"/g'); echo \")\"")
1838 (tramp-shell-quote-argument localname) 1834 (tramp-shell-quote-argument localname)
1839 (tramp-get-ls-command vec) 1835 (tramp-get-ls-command vec)
1840 ;; On systems which have no quoting style, file names with 1836 ;; On systems which have no quoting style, file names with special
1841 ;; special characters could fail. 1837 ;; characters could fail.
1842 (if (tramp-get-ls-command-with-quoting-style vec) 1838 (cond
1843 "--quoting-style=shell" "") 1839 ((tramp-get-ls-command-with-quoting-style vec)
1840 "--quoting-style=shell")
1841 ((tramp-get-ls-command-with-w-option vec)
1842 "-w")
1843 (t ""))
1844 (tramp-get-remote-stat vec) 1844 (tramp-get-remote-stat vec)
1845 tramp-stat-marker tramp-stat-marker 1845 tramp-stat-marker tramp-stat-marker
1846 tramp-stat-marker tramp-stat-marker 1846 tramp-stat-marker tramp-stat-marker
@@ -5417,6 +5417,14 @@ Return ATTR."
5417 vec (format "%s --quoting-style=shell -al /dev/null" 5417 vec (format "%s --quoting-style=shell -al /dev/null"
5418 (tramp-get-ls-command vec)))))) 5418 (tramp-get-ls-command vec))))))
5419 5419
5420(defun tramp-get-ls-command-with-w-option (vec)
5421 (save-match-data
5422 (with-tramp-connection-property vec "ls-w-option"
5423 (tramp-message vec 5 "Checking, whether `ls -w' works")
5424 ;; Option "-w" is available on BSD systems.
5425 (tramp-send-command-and-check
5426 vec (format "%s -alw /dev/null" (tramp-get-ls-command vec))))))
5427
5420(defun tramp-get-test-command (vec) 5428(defun tramp-get-test-command (vec)
5421 (with-tramp-connection-property vec "test" 5429 (with-tramp-connection-property vec "test"
5422 (tramp-message vec 5 "Finding a suitable `test' command") 5430 (tramp-message vec 5 "Finding a suitable `test' command")
diff --git a/test/automated/tramp-tests.el b/test/automated/tramp-tests.el
index c5cab7d5991..8a1743cd200 100644
--- a/test/automated/tramp-tests.el
+++ b/test/automated/tramp-tests.el
@@ -1987,7 +1987,10 @@ Use the `perl' command."
1987 (let ((tramp-connection-properties 1987 (let ((tramp-connection-properties
1988 (append 1988 (append
1989 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory)) 1989 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
1990 "stat" nil)) 1990 "stat" nil)
1991 ;; See `tramp-sh-handle-file-truename'.
1992 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
1993 "readlink" nil))
1991 tramp-connection-properties))) 1994 tramp-connection-properties)))
1992 (tramp--test-special-characters))) 1995 (tramp--test-special-characters)))
1993 1996
@@ -2005,7 +2008,10 @@ Use the `ls' command."
2005 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory)) 2008 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2006 "perl" nil) 2009 "perl" nil)
2007 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory)) 2010 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2008 "stat" nil)) 2011 "stat" nil)
2012 ;; See `tramp-sh-handle-file-truename'.
2013 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2014 "readlink" nil))
2009 tramp-connection-properties))) 2015 tramp-connection-properties)))
2010 (tramp--test-special-characters))) 2016 (tramp--test-special-characters)))
2011 2017
@@ -2059,7 +2065,10 @@ Use the `perl' command."
2059 (let ((tramp-connection-properties 2065 (let ((tramp-connection-properties
2060 (append 2066 (append
2061 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory)) 2067 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2062 "stat" nil)) 2068 "stat" nil)
2069 ;; See `tramp-sh-handle-file-truename'.
2070 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2071 "readlink" nil))
2063 tramp-connection-properties))) 2072 tramp-connection-properties)))
2064 (tramp--test-utf8))) 2073 (tramp--test-utf8)))
2065 2074
@@ -2077,7 +2086,10 @@ Use the `ls' command."
2077 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory)) 2086 `((,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2078 "perl" nil) 2087 "perl" nil)
2079 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory)) 2088 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2080 "stat" nil)) 2089 "stat" nil)
2090 ;; See `tramp-sh-handle-file-truename'.
2091 (,(regexp-quote (file-remote-p tramp-test-temporary-file-directory))
2092 "readlink" nil))
2081 tramp-connection-properties))) 2093 tramp-connection-properties)))
2082 (tramp--test-utf8))) 2094 (tramp--test-utf8)))
2083 2095