]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix Tramp portability issues
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 2 Aug 2020 11:26:00 +0000 (13:26 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 2 Aug 2020 11:26:00 +0000 (13:26 +0200)
* 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.

lisp/net/tramp-sh.el
test/lisp/net/tramp-tests.el

index 9f37207def1975f34592a4c0e6999f77508aa342..f9f0cbcc023483e8a85e7ace0c84fb3ff926e222 100644 (file)
@@ -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))
index 19da15acafa66a6137c6d4a893363464a8c03133..ac24fcf280a37b52e2393fb0bb716608711d6bf5 100644 (file)
@@ -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)))