aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/net/tramp-sh.el4
-rw-r--r--lisp/net/tramp.el10
-rw-r--r--test/lisp/net/tramp-tests.el144
3 files changed, 104 insertions, 54 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 31ef2efbf20..fbf44b77a12 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -5169,8 +5169,8 @@ Return ATTR."
5169 ((tramp-get-method-parameter vec 'tramp-remote-copy-program) 5169 ((tramp-get-method-parameter vec 'tramp-remote-copy-program)
5170 localname) 5170 localname)
5171 ((not (zerop (length user))) 5171 ((not (zerop (length user)))
5172 (tramp-shell-quote-argument (format "%s@%s:%s" user host localname))) 5172 (format "%s@%s:%s" user host (shell-quote-argument localname)))
5173 (t (tramp-shell-quote-argument (format "%s:%s" host localname)))))) 5173 (t (format "%s:%s" host (shell-quote-argument localname))))))
5174 5174
5175(defun tramp-method-out-of-band-p (vec size) 5175(defun tramp-method-out-of-band-p (vec size)
5176 "Return t if this is an out-of-band method, nil otherwise." 5176 "Return t if this is an out-of-band method, nil otherwise."
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 7987029dc44..da745524a14 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -1691,9 +1691,13 @@ locally on a remote file name. When the local system is a W32 system
1691but the remote system is Unix, this introduces a superfluous drive 1691but the remote system is Unix, this introduces a superfluous drive
1692letter into the file name. This function removes it." 1692letter into the file name. This function removes it."
1693 (save-match-data 1693 (save-match-data
1694 (if (string-match "\\`[a-zA-Z]:/" name) 1694 (funcall
1695 (replace-match "/" nil t name) 1695 (if (tramp-compat-file-name-quoted-p name)
1696 name))) 1696 'tramp-compat-file-name-quote 'identity)
1697 (let ((name (tramp-compat-file-name-unquote name)))
1698 (if (string-match "\\`[a-zA-Z]:/" name)
1699 (replace-match "/" nil t name)
1700 name)))))
1697 1701
1698;;; Config Manipulation Functions: 1702;;; Config Manipulation Functions:
1699 1703
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 893dc543f3e..ee8a95e7bd5 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -682,8 +682,8 @@ handled properly. BODY shall not contain a timeout."
682 (expand-file-name "/method:host:/:/path/../file") "/method:host:/:/file")) 682 (expand-file-name "/method:host:/:/path/../file") "/method:host:/:/file"))
683 (should 683 (should
684 (string-equal 684 (string-equal
685 (expand-file-name "/method:host:/:~/path/./file") 685 (expand-file-name "/method:host:/:/~/path/./file")
686 "/method:host:/:~/path/file"))) 686 "/method:host:/:/~/path/file")))
687 687
688(ert-deftest tramp-test06-directory-file-name () 688(ert-deftest tramp-test06-directory-file-name ()
689 "Check `directory-file-name'. 689 "Check `directory-file-name'.
@@ -2120,6 +2120,14 @@ This does not support globbing characters in file names (yet)."
2120This requires restrictions of file name syntax." 2120This requires restrictions of file name syntax."
2121 (tramp-gvfs-file-name-p tramp-test-temporary-file-directory)) 2121 (tramp-gvfs-file-name-p tramp-test-temporary-file-directory))
2122 2122
2123(defun tramp--test-hpux-p ()
2124 "Check, whether the remote host runs HP-UX.
2125Several special characters do not work properly there."
2126 ;; We must refill the cache. `file-truename' does it.
2127 (with-parsed-tramp-file-name
2128 (file-truename tramp-test-temporary-file-directory) nil
2129 (string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
2130
2123(defun tramp--test-rsync-p () 2131(defun tramp--test-rsync-p ()
2124 "Check, whether the rsync method is used. 2132 "Check, whether the rsync method is used.
2125This does not support special file names." 2133This does not support special file names."
@@ -2132,23 +2140,28 @@ This does not support special file names."
2132 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory) 2140 (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
2133 'tramp-sh-file-name-handler)) 2141 'tramp-sh-file-name-handler))
2134 2142
2135(defun tramp--test-smb-or-windows-nt-p () 2143(defun tramp--test-windows-nt-and-batch ()
2144 "Check, whether the locale host runs MS Windows in batch mode.
2145This does not support scpecial characters."
2146 (and (eq system-type 'windows-nt) noninteractive))
2147
2148(defun tramp--test-windows-nt-and-pscp-psftp-p ()
2149 "Check, whether the locale host runs MS Windows, and ps{cp,ftp} is used.
2150This does not support utf8 based file transfer."
2151 (and (eq system-type 'windows-nt)
2152 (string-match
2153 (regexp-opt '("pscp" "psftp"))
2154 (file-remote-p tramp-test-temporary-file-directory 'method))))
2155
2156(defun tramp--test-windows-nt-or-smb-p ()
2136 "Check, whether the locale or remote host runs MS Windows. 2157 "Check, whether the locale or remote host runs MS Windows.
2137This requires restrictions of file name syntax." 2158This requires restrictions of file name syntax."
2138 (or (eq system-type 'windows-nt) 2159 (or (eq system-type 'windows-nt)
2139 (tramp-smb-file-name-p tramp-test-temporary-file-directory))) 2160 (tramp-smb-file-name-p tramp-test-temporary-file-directory)))
2140 2161
2141(defun tramp--test-hpux-p ()
2142 "Check, whether the remote host runs HP-UX.
2143Several special characters do not work properly there."
2144 ;; We must refill the cache. `file-truename' does it.
2145 (with-parsed-tramp-file-name
2146 (file-truename tramp-test-temporary-file-directory) nil
2147 (string-match "^HP-UX" (tramp-get-connection-property v "uname" ""))))
2148
2149(defun tramp--test-check-files (&rest files) 2162(defun tramp--test-check-files (&rest files)
2150 "Run a simple but comprehensive test over every file in FILES." 2163 "Run a simple but comprehensive test over every file in FILES."
2151 (dolist (quoted '(if tramp--test-expensive-test '(nil t) '(nil))) 2164 (dolist (quoted (if tramp--test-expensive-test '(nil t) '(nil)))
2152 ;; We must use `file-truename' for the temporary directory, 2165 ;; We must use `file-truename' for the temporary directory,
2153 ;; because it could be located on a symlinked directory. This 2166 ;; because it could be located on a symlinked directory. This
2154 ;; would let the test fail. 2167 ;; would let the test fail.
@@ -2156,11 +2169,25 @@ Several special characters do not work properly there."
2156 (file-truename tramp-test-temporary-file-directory)) 2169 (file-truename tramp-test-temporary-file-directory))
2157 (tmp-name1 (tramp--test-make-temp-name nil quoted)) 2170 (tmp-name1 (tramp--test-make-temp-name nil quoted))
2158 (tmp-name2 (tramp--test-make-temp-name 'local quoted)) 2171 (tmp-name2 (tramp--test-make-temp-name 'local quoted))
2159 (files (delq nil files))) 2172 (files (delq nil files))
2173 (process-environment process-environment))
2160 (unwind-protect 2174 (unwind-protect
2161 (progn 2175 (progn
2176 ;; Add environment variables.
2177 (dolist (elt files)
2178 ;; The check command (heredoc file) does not support
2179 ;; environment variables with leading spaces.
2180 (let* ((elt (replace-regexp-in-string "^\\s-+" "" elt))
2181 (envvar (concat "VAR_" (upcase (md5 elt)))))
2182 (setenv envvar elt)))
2183
2184 ;; We force a reconnect, in order to have a clean environment.
2185 (tramp-cleanup-connection
2186 (tramp-dissect-file-name tramp-test-temporary-file-directory)
2187 'keep-debug 'keep-password)
2162 (make-directory tmp-name1) 2188 (make-directory tmp-name1)
2163 (make-directory tmp-name2) 2189 (make-directory tmp-name2)
2190
2164 (dolist (elt files) 2191 (dolist (elt files)
2165 (let* ((file1 (expand-file-name elt tmp-name1)) 2192 (let* ((file1 (expand-file-name elt tmp-name1))
2166 (file2 (expand-file-name elt tmp-name2)) 2193 (file2 (expand-file-name elt tmp-name2))
@@ -2287,30 +2314,30 @@ Several special characters do not work properly there."
2287 2314
2288 ;; Check, that environment variables are set correctly. 2315 ;; Check, that environment variables are set correctly.
2289 (when (and tramp--test-expensive-test (tramp--test-sh-p)) 2316 (when (and tramp--test-expensive-test (tramp--test-sh-p))
2290 (dolist (elt files) 2317 (dolist (elt process-environment)
2291 ;; Tramp does not support environment variables with 2318 (when (string-match "^VAR_" elt)
2292 ;; leading or trailing spaces. It also does not 2319 (let* ((default-directory tramp-test-temporary-file-directory)
2293 ;; support the tab character. 2320 (shell-file-name "/bin/sh")
2294 (setq elt (replace-regexp-in-string "\t" " " elt) 2321 (heredoc (md5 (current-time-string)))
2295 elt (replace-regexp-in-string "^\\s-+\\|\\s-+$" "" elt)) 2322 (envvar (car (split-string elt "=" t)))
2296 (let* ((default-directory tramp-test-temporary-file-directory) 2323 (file1 (tramp-compat-file-name-unquote
2297 (shell-file-name "/bin/sh") 2324 (expand-file-name "bar" tmp-name1))))
2298 (envvar 2325 ;; Cleanup.
2299 (concat "VAR_" (upcase (md5 (current-time-string))))) 2326 (ignore-errors (delete-file file1))
2300 (tramp-remote-process-environment 2327 ;; Save the variable in a file. The echo command
2301 (cons 2328 ;; does not work properly, it suppresses leading/
2302 (format "%s=%s" envvar elt) 2329 ;; trailing spaces as well as tabs.
2303 tramp-remote-process-environment)))
2304 ;; We force a reconnect, in order to have a clean
2305 ;; environment.
2306 (tramp-cleanup-connection
2307 (tramp-dissect-file-name tramp-test-temporary-file-directory)
2308 'keep-debug 'keep-password)
2309 (should
2310 (string-equal
2311 elt
2312 (shell-command-to-string 2330 (shell-command-to-string
2313 (format "echo -n $%s" envvar)))))))) 2331 (format
2332 "cat <<%s >%s\n$%s\n%s"
2333 heredoc (file-remote-p file1 'localname) envvar heredoc))
2334 (with-temp-buffer
2335 (insert-file-contents file1)
2336 (should
2337 (string-equal
2338 (buffer-string) (concat (getenv envvar) "\n"))))
2339 (delete-file file1)
2340 (should-not (file-exists-p file1)))))))
2314 2341
2315 ;; Cleanup. 2342 ;; Cleanup.
2316 (ignore-errors (delete-directory tmp-name1 'recursive)) 2343 (ignore-errors (delete-directory tmp-name1 'recursive))
@@ -2324,7 +2351,7 @@ Several special characters do not work properly there."
2324 ;; interpreted as a path separator, preventing "\t" from being 2351 ;; interpreted as a path separator, preventing "\t" from being
2325 ;; expanded to <TAB>. 2352 ;; expanded to <TAB>.
2326 (tramp--test-check-files 2353 (tramp--test-check-files
2327 (if (or (tramp--test-gvfs-p) (tramp--test-smb-or-windows-nt-p)) 2354 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
2328 "foo bar baz" 2355 "foo bar baz"
2329 (if (or (tramp--test-adb-p) 2356 (if (or (tramp--test-adb-p)
2330 (tramp--test-docker-p) 2357 (tramp--test-docker-p)
@@ -2337,23 +2364,23 @@ Several special characters do not work properly there."
2337 "&foo&bar&baz&" 2364 "&foo&bar&baz&"
2338 (unless (or (tramp--test-ftp-p) 2365 (unless (or (tramp--test-ftp-p)
2339 (tramp--test-gvfs-p) 2366 (tramp--test-gvfs-p)
2340 (tramp--test-smb-or-windows-nt-p)) 2367 (tramp--test-windows-nt-or-smb-p))
2341 "?foo?bar?baz?") 2368 "?foo?bar?baz?")
2342 (unless (or (tramp--test-ftp-p) 2369 (unless (or (tramp--test-ftp-p)
2343 (tramp--test-gvfs-p) 2370 (tramp--test-gvfs-p)
2344 (tramp--test-smb-or-windows-nt-p)) 2371 (tramp--test-windows-nt-or-smb-p))
2345 "*foo*bar*baz*") 2372 "*foo*bar*baz*")
2346 (if (or (tramp--test-gvfs-p) (tramp--test-smb-or-windows-nt-p)) 2373 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
2347 "'foo'bar'baz'" 2374 "'foo'bar'baz'"
2348 "'foo\"bar'baz\"") 2375 "'foo\"bar'baz\"")
2349 "#foo~bar#baz~" 2376 "#foo~bar#baz~"
2350 (if (or (tramp--test-gvfs-p) (tramp--test-smb-or-windows-nt-p)) 2377 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
2351 "!foo!bar!baz!" 2378 "!foo!bar!baz!"
2352 "!foo|bar!baz|") 2379 "!foo|bar!baz|")
2353 (if (or (tramp--test-gvfs-p) (tramp--test-smb-or-windows-nt-p)) 2380 (if (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
2354 ";foo;bar;baz;" 2381 ";foo;bar;baz;"
2355 ":foo;bar:baz;") 2382 ":foo;bar:baz;")
2356 (unless (or (tramp--test-gvfs-p) (tramp--test-smb-or-windows-nt-p)) 2383 (unless (or (tramp--test-gvfs-p) (tramp--test-windows-nt-or-smb-p))
2357 "<foo>bar<baz>") 2384 "<foo>bar<baz>")
2358 "(foo)bar(baz)" 2385 "(foo)bar(baz)"
2359 (unless (or (tramp--test-ftp-p) (tramp--test-gvfs-p)) "[foo]bar[baz]") 2386 (unless (or (tramp--test-ftp-p) (tramp--test-gvfs-p)) "[foo]bar[baz]")
@@ -2364,6 +2391,7 @@ Several special characters do not work properly there."
2364 "Check special characters in file names." 2391 "Check special characters in file names."
2365 (skip-unless (tramp--test-enabled)) 2392 (skip-unless (tramp--test-enabled))
2366 (skip-unless (not (tramp--test-rsync-p))) 2393 (skip-unless (not (tramp--test-rsync-p)))
2394 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2367 2395
2368 (tramp--test-special-characters)) 2396 (tramp--test-special-characters))
2369 2397
@@ -2372,7 +2400,9 @@ Several special characters do not work properly there."
2372Use the `stat' command." 2400Use the `stat' command."
2373 :tags '(:expensive-test) 2401 :tags '(:expensive-test)
2374 (skip-unless (tramp--test-enabled)) 2402 (skip-unless (tramp--test-enabled))
2375 (skip-unless (and (tramp--test-sh-p) (not (tramp--test-rsync-p)))) 2403 (skip-unless (tramp--test-sh-p))
2404 (skip-unless (not (tramp--test-rsync-p)))
2405 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2376 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil 2406 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
2377 (skip-unless (tramp-get-remote-stat v))) 2407 (skip-unless (tramp-get-remote-stat v)))
2378 2408
@@ -2388,7 +2418,9 @@ Use the `stat' command."
2388Use the `perl' command." 2418Use the `perl' command."
2389 :tags '(:expensive-test) 2419 :tags '(:expensive-test)
2390 (skip-unless (tramp--test-enabled)) 2420 (skip-unless (tramp--test-enabled))
2391 (skip-unless (and (tramp--test-sh-p) (not (tramp--test-rsync-p)))) 2421 (skip-unless (tramp--test-sh-p))
2422 (skip-unless (not (tramp--test-rsync-p)))
2423 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2392 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil 2424 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
2393 (skip-unless (tramp-get-remote-perl v))) 2425 (skip-unless (tramp-get-remote-perl v)))
2394 2426
@@ -2407,7 +2439,10 @@ Use the `perl' command."
2407Use the `ls' command." 2439Use the `ls' command."
2408 :tags '(:expensive-test) 2440 :tags '(:expensive-test)
2409 (skip-unless (tramp--test-enabled)) 2441 (skip-unless (tramp--test-enabled))
2410 (skip-unless (and (tramp--test-sh-p) (not (tramp--test-rsync-p)))) 2442 (skip-unless (tramp--test-sh-p))
2443 (skip-unless (not (tramp--test-rsync-p)))
2444 (skip-unless (not (tramp--test-windows-nt-and-batch)))
2445 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2411 2446
2412 (let ((tramp-connection-properties 2447 (let ((tramp-connection-properties
2413 (append 2448 (append
@@ -2441,6 +2476,8 @@ Use the `ls' command."
2441 (skip-unless (tramp--test-enabled)) 2476 (skip-unless (tramp--test-enabled))
2442 (skip-unless (not (tramp--test-docker-p))) 2477 (skip-unless (not (tramp--test-docker-p)))
2443 (skip-unless (not (tramp--test-rsync-p))) 2478 (skip-unless (not (tramp--test-rsync-p)))
2479 (skip-unless (not (tramp--test-windows-nt-and-batch)))
2480 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2444 2481
2445 (tramp--test-utf8)) 2482 (tramp--test-utf8))
2446 2483
@@ -2449,8 +2486,11 @@ Use the `ls' command."
2449Use the `stat' command." 2486Use the `stat' command."
2450 :tags '(:expensive-test) 2487 :tags '(:expensive-test)
2451 (skip-unless (tramp--test-enabled)) 2488 (skip-unless (tramp--test-enabled))
2489 (skip-unless (tramp--test-sh-p))
2452 (skip-unless (not (tramp--test-docker-p))) 2490 (skip-unless (not (tramp--test-docker-p)))
2453 (skip-unless (and (tramp--test-sh-p) (not (tramp--test-rsync-p)))) 2491 (skip-unless (not (tramp--test-rsync-p)))
2492 (skip-unless (not (tramp--test-windows-nt-and-batch)))
2493 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2454 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil 2494 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
2455 (skip-unless (tramp-get-remote-stat v))) 2495 (skip-unless (tramp-get-remote-stat v)))
2456 2496
@@ -2466,8 +2506,11 @@ Use the `stat' command."
2466Use the `perl' command." 2506Use the `perl' command."
2467 :tags '(:expensive-test) 2507 :tags '(:expensive-test)
2468 (skip-unless (tramp--test-enabled)) 2508 (skip-unless (tramp--test-enabled))
2509 (skip-unless (tramp--test-sh-p))
2469 (skip-unless (not (tramp--test-docker-p))) 2510 (skip-unless (not (tramp--test-docker-p)))
2470 (skip-unless (and (tramp--test-sh-p) (not (tramp--test-rsync-p)))) 2511 (skip-unless (not (tramp--test-rsync-p)))
2512 (skip-unless (not (tramp--test-windows-nt-and-batch)))
2513 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2471 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil 2514 (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil
2472 (skip-unless (tramp-get-remote-perl v))) 2515 (skip-unless (tramp-get-remote-perl v)))
2473 2516
@@ -2486,8 +2529,11 @@ Use the `perl' command."
2486Use the `ls' command." 2529Use the `ls' command."
2487 :tags '(:expensive-test) 2530 :tags '(:expensive-test)
2488 (skip-unless (tramp--test-enabled)) 2531 (skip-unless (tramp--test-enabled))
2532 (skip-unless (tramp--test-sh-p))
2489 (skip-unless (not (tramp--test-docker-p))) 2533 (skip-unless (not (tramp--test-docker-p)))
2490 (skip-unless (and (tramp--test-sh-p) (not (tramp--test-rsync-p)))) 2534 (skip-unless (not (tramp--test-rsync-p)))
2535 (skip-unless (not (tramp--test-windows-nt-and-batch)))
2536 (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p)))
2491 2537
2492 (let ((tramp-connection-properties 2538 (let ((tramp-connection-properties
2493 (append 2539 (append