all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: Sylvain Chouleur <sylvain.chouleur@gmail.com>
Cc: 16582@debbugs.gnu.org
Subject: bug#16582: Bug: tramp shell command doesn't read stdin
Date: Mon, 03 Feb 2014 13:53:36 +0100	[thread overview]
Message-ID: <87eh3k5pdb.fsf@gmx.de> (raw)
In-Reply-To: <CAD_mUW385R3XGtHy5vqCf5LbCX+yj=7ps4bE=uUfd4kfBseraw@mail.gmail.com> (Sylvain Chouleur's message of "Sun, 2 Feb 2014 15:27:35 +0100")

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

Sylvain Chouleur <sylvain.chouleur@gmail.com> writes:

> Hi,

Hi Sylvain,

> Here is my proposal (patch in attachment)
>
> exec env PS1=.. bash <(cat <<'EOF'
> heredoc commands
> EOF
> )

Thanks for this. However, I'm not sure whether all bourne shell
derivates support process substitution <().

What if Tramp uses another heredoc delimeter but 'EOF'? I've appended a
respective patch; could you, please, check?

If it doesn't work for you, please set tramp-verbose to 6, and rerun
your test. I would like to see the Tramp debug buffer then. Explain
also, what you have invoked, and how.

Best regards, Michael.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: diff --]
[-- Type: text/x-diff, Size: 3936 bytes --]

diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index 65d5f27..67a517a 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -79,6 +79,9 @@ detected as prompt when being sent on echoing hosts, therefore.")
 (defconst tramp-initial-end-of-output "#$ "
   "Prompt when establishing a connection.")
 
+(defconst tramp-end-of-heredoc (md5 tramp-end-of-output)
+  "String used to recognize end of heredoc strings.")
+
 ;; Initialize `tramp-methods' with the supported methods.
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
@@ -1443,8 +1446,11 @@ be non-negative integers."
     (if (and (stringp acl-string) (tramp-remote-acl-p v)
 	     (progn
 	       (tramp-send-command
-		v (format "setfacl --set-file=- %s <<'EOF'\n%s\nEOF\n"
-			  (tramp-shell-quote-argument localname) acl-string))
+		v (format "setfacl --set-file=- %s <<'%s'\n%s\n%s\n"
+			  (tramp-shell-quote-argument localname)
+			  tramp-end-of-heredoc
+			  acl-string
+			  tramp-end-of-heredoc))
 	       (tramp-send-command-and-check v nil)))
 	;; Success.
 	(progn
@@ -2707,14 +2713,15 @@ the result will be a local, non-Tramp, filename."
 	    (when (stringp program)
 	      (format "cd %s; exec %s env PS1=%s %s"
 		      (tramp-shell-quote-argument localname)
-		      (if heredoc "<<EOF" "")
+		      (if heredoc (format "<<'%s'" tramp-end-of-heredoc) "")
 		      ;; Use a human-friendly prompt, for example for `shell'.
 		      (tramp-shell-quote-argument
 		       (format "%s %s"
 			       (file-remote-p default-directory)
 			       tramp-initial-end-of-output))
 		      (if heredoc
-			  (format "%s\n%s\nEOF" program (car args))
+			  (format "%s\n%s\n%s"
+				  program (car args) tramp-end-of-heredoc)
 			(mapconcat 'tramp-shell-quote-argument
 				   (cons program args) " ")))))
 	   (tramp-process-connection-type
@@ -3182,9 +3189,11 @@ the result will be a local, non-Tramp, filename."
 		      (tramp-send-command
 		       v
 		       (format
-			(concat rem-dec " <<'EOF'\n%sEOF")
+			(concat rem-dec " <<'%s'\n%s%s")
 			(tramp-shell-quote-argument localname)
-			(buffer-string)))
+			tramp-end-of-heredoc
+			(buffer-string)
+			tramp-end-of-heredoc))
 		      (tramp-barf-unless-okay
 		       v nil
 		       "Couldn't write region to `%s', decode using `%s' failed"
@@ -3302,10 +3311,12 @@ the result will be a local, non-Tramp, filename."
 		 (tramp-send-command-and-read
 		  v
 		  (format
-		   "tramp_vc_registered_read_file_names <<'EOF'\n%s\nEOF\n"
+		   "tramp_vc_registered_read_file_names <<'%s'\n%s\n%s\n"
+		   tramp-end-of-heredoc
 		   (mapconcat 'tramp-shell-quote-argument
 			      tramp-vc-registered-file-names
-			      "\n"))))
+			      "\n")
+		   tramp-end-of-heredoc)))
 
 	      (tramp-set-file-property
 	       v (car elt) (cadr elt) (cadr (cdr elt))))))
@@ -3580,9 +3591,12 @@ This function expects to be in the right *tramp* buffer."
 	 (format (concat "while read d; "
 			 "do if test -x $d/%s -a -f $d/%s; "
 			 "then echo tramp_executable $d/%s; "
-			 "break; fi; done <<'EOF'\n"
-			 "%s\nEOF")
-		 progname progname progname (mapconcat 'identity dirlist "\n")))
+			 "break; fi; done <<'%s'\n"
+			 "%s\n%s")
+		 progname progname progname
+		 tramp-end-of-heredoc
+		 (mapconcat 'identity dirlist "\n")
+		 tramp-end-of-heredoc))
 	(goto-char (point-max))
 	(when (search-backward "tramp_executable " nil t)
 	  (skip-chars-forward "^ ")
@@ -4560,7 +4574,7 @@ function waits for output unless NOOUTPUT is set."
     ;; Some busyboxes tend to close the connection when we use the
     ;; following syntax for here-documents.  This we cannot test; it
     ;; shall be set via `tramp-connection-properties'.
-    (when (and (string-match "<<'EOF'" command)
+    (when (and (string-match (format "<<'%s'" tramp-end-of-heredoc) command)
 	       (not (tramp-get-connection-property vec "busybox" nil)))
       ;; Unset $PS1 when using here documents, in order to avoid
       ;; multiple prompts.

  reply	other threads:[~2014-02-03 12:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-28 22:40 bug#16582: Bug: tramp shell command doesn't read stdin Sylvain Chouleur
2014-01-29 14:35 ` Michael Albinus
2014-02-02 14:27   ` Sylvain Chouleur
2014-02-03 12:53     ` Michael Albinus [this message]
2014-02-04 22:53       ` Sylvain Chouleur
2014-02-05  8:29         ` Michael Albinus
2014-02-05  9:44           ` Sylvain Chouleur
2014-02-05 10:27             ` Michael Albinus
2014-02-05 12:27               ` Sylvain Chouleur
2014-02-05 14:04                 ` Michael Albinus
2014-02-05 14:44                   ` Sylvain Chouleur
2014-02-05 15:33                     ` Michael Albinus
2014-02-05 21:01                       ` Sylvain Chouleur
2014-02-06  8:52                         ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eh3k5pdb.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=16582@debbugs.gnu.org \
    --cc=sylvain.chouleur@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.