Commit dc8aa154 authored by Michael Albinus's avatar Michael Albinus

Fix Tramp portability issues

* lisp/net/tramp-sh.el (tramp-set-remote-path): Replace "echo -n" by
"printf", it isn't portable.

* test/lisp/net/tramp-tests.el (tramp-test33-environment-variables)
(tramp-test33-environment-variables-and-port-numbers): Do not use
"echo -n", it isn't portable.
(tramp--test-utf8): Filter out not displayable characters.
parent 069b58b7
Pipeline #6200 failed with stage
in 61 minutes and 41 seconds
......@@ -4079,7 +4079,7 @@ variable PATH."
chunk (substring command 0 chunksize)
command (substring command chunksize))
(tramp-send-command vec (format
"echo -n %s >>%s"
"printf \"%%b\" \"$*\" %s >>%s"
(tramp-shell-quote-argument chunk)
(tramp-shell-quote-argument tmpfile))))
(tramp-send-command vec (format ". %s" tmpfile))
......
......@@ -4933,16 +4933,16 @@ INPUT, if non-nil, is a string sent to the process."
(setenv "INSIDE_EMACS")
(should
(string-equal
(format "%s,tramp:%s" emacs-version tramp-version)
(funcall this-shell-command-to-string "echo -n ${INSIDE_EMACS:-bla}")))
(format "%s,tramp:%s\n" emacs-version tramp-version)
(funcall this-shell-command-to-string "echo ${INSIDE_EMACS:-bla}")))
(let ((process-environment
(cons (format "INSIDE_EMACS=%s,foo" emacs-version)
process-environment)))
(should
(string-equal
(format "%s,foo,tramp:%s" emacs-version tramp-version)
(format "%s,foo,tramp:%s\n" emacs-version tramp-version)
(funcall
this-shell-command-to-string "echo -n ${INSIDE_EMACS:-bla}"))))
this-shell-command-to-string "echo ${INSIDE_EMACS:-bla}"))))
;; Set a value.
(let ((process-environment
......@@ -4952,7 +4952,7 @@ INPUT, if non-nil, is a string sent to the process."
(string-match
"foo"
(funcall
this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar)))))
this-shell-command-to-string (format "echo ${%s:-bla}" envvar)))))
;; Set the empty value.
(let ((process-environment
......@@ -4962,7 +4962,7 @@ INPUT, if non-nil, is a string sent to the process."
(string-match
"bla"
(funcall
this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar))))
this-shell-command-to-string (format "echo ${%s:-bla}" envvar))))
;; Variable is set.
(should
(string-match
......@@ -4979,15 +4979,14 @@ INPUT, if non-nil, is a string sent to the process."
(string-match
"foo"
(funcall
this-shell-command-to-string (format "echo -n ${%s:-bla}" envvar))))
this-shell-command-to-string (format "echo ${%s:-bla}" envvar))))
(let ((process-environment (cons envvar process-environment)))
;; Variable is unset.
(should
(string-match
"bla"
(funcall
this-shell-command-to-string
(format "echo -n ${%s:-bla}" envvar))))
this-shell-command-to-string (format "echo ${%s:-bla}" envvar))))
;; Variable is unset.
(should-not
(string-match
......@@ -5026,7 +5025,7 @@ INPUT, if non-nil, is a string sent to the process."
(should
(string-match
(number-to-string port)
(shell-command-to-string (format "echo -n $%s" envvar))))))
(shell-command-to-string (format "echo $%s" envvar))))))
;; Cleanup.
(dolist (dir '("/mock:localhost#11111:" "/mock:localhost#22222:"))
......@@ -6051,6 +6050,12 @@ Use the `ls' command."
(not (and (or (tramp--test-gvfs-p) (tramp--test-smb-p))
(unencodable-char-position
0 (length x) file-name-coding-system nil x)))
;; Filter out not displayable characters.
(setq x (mapconcat
(lambda (y)
(and (char-displayable-p y) (char-to-string y)))
x ""))
(not (string-empty-p x))
;; ?\n and ?/ shouldn't be part of any file name. ?\t,
;; ?. and ?? do not work for "smb" method.
(replace-regexp-in-string "[\t\n/.?]" "" x)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment