[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master dc8aa15: Fix Tramp portability issues
From: |
Michael Albinus |
Subject: |
master dc8aa15: Fix Tramp portability issues |
Date: |
Sun, 2 Aug 2020 07:26:09 -0400 (EDT) |
branch: master
commit dc8aa15472dc5df5f903e6a3b150e2f03eeb2dd1
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>
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.
---
lisp/net/tramp-sh.el | 2 +-
test/lisp/net/tramp-tests.el | 25 +++++++++++++++----------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 9f37207..f9f0cbc 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -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))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 19da15a..ac24fcf 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -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)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master dc8aa15: Fix Tramp portability issues,
Michael Albinus <=