Petr Hracek c88b79
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
Petr Hracek c88b79
index 29a6344..f6c6710 100644
Petr Hracek c88b79
--- a/lisp/net/tramp-sh.el
Petr Hracek c88b79
+++ b/lisp/net/tramp-sh.el
Petr Hracek c88b79
@@ -605,9 +605,9 @@ This list is used for copying/renaming with out-of-band methods.
Petr Hracek c88b79
 See `tramp-actions-before-shell' for more info.")
Petr Hracek c88b79
 
Petr Hracek c88b79
 (defconst tramp-uudecode
Petr Hracek c88b79
-  "(echo begin 600 /tmp/tramp.$$; tail +2) | uudecode
Petr Hracek c88b79
-cat /tmp/tramp.$$
Petr Hracek c88b79
-rm -f /tmp/tramp.$$"
Petr Hracek c88b79
+  "(echo begin 600 %t; tail +2) | uudecode
Petr Hracek c88b79
+cat %t
Petr Hracek c88b79
+rm -f %t"
Petr Hracek c88b79
   "Shell function to implement `uudecode' to standard output.
Petr Hracek c88b79
 Many systems support `uudecode -o /dev/stdout' or `uudecode -o -'
Petr Hracek c88b79
 for this or `uudecode -p', but some systems don't, and for them
Petr Hracek c88b79
@@ -3938,7 +3938,7 @@ Each item is a list that looks like this:
Petr Hracek c88b79
 
Petr Hracek c88b79
 \(FORMAT ENCODING DECODING [TEST]\)
Petr Hracek c88b79
 
Petr Hracek c88b79
-FORMAT is  symbol describing the encoding/decoding format.  It can be
Petr Hracek c88b79
+FORMAT is a symbol describing the encoding/decoding format.  It can be
Petr Hracek c88b79
 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing.
Petr Hracek c88b79
 
Petr Hracek c88b79
 ENCODING and DECODING can be strings, giving commands, or symbols,
Petr Hracek c88b79
@@ -3948,9 +3948,11 @@ filename will be put into the command line at that spot.  If the
Petr Hracek c88b79
 specifier is not present, the input should be read from standard
Petr Hracek c88b79
 input.
Petr Hracek c88b79
 
Petr Hracek c88b79
-If they are variables, this variable is a string containing a Perl
Petr Hracek c88b79
-implementation for this functionality.  This Perl program will be transferred
Petr Hracek c88b79
-to the remote host, and it is available as shell function with the same name.
Petr Hracek c88b79
+If they are variables, this variable is a string containing a
Petr Hracek c88b79
+Perl or Shell implementation for this functionality.  This
Petr Hracek c88b79
+program will be transferred to the remote host, and it is
Petr Hracek c88b79
+available as shell function with the same name. A \"%t\" format
Petr Hracek c88b79
+specifier in the variable value denotes a temporary file
Petr Hracek c88b79
 
Petr Hracek c88b79
 The optional TEST command can be used for further tests, whether
Petr Hracek c88b79
 ENCODING and DECODING are applicable.")
Petr Hracek c88b79
@@ -4025,10 +4027,25 @@ Goes through the list `tramp-local-coding-commands' and
Petr Hracek c88b79
 		    (throw 'wont-work-remote nil))
Petr Hracek c88b79
 
Petr Hracek c88b79
 		  (when (not (stringp rem-dec))
Petr Hracek c88b79
-		    (let ((name (symbol-name rem-dec)))
Petr Hracek c88b79
+		    (let ((name (symbol-name rem-dec))
Petr Hracek c88b79
+                  (value (symbol-value rem-dec))
Petr Hracek c88b79
+                  tmpfile)
Petr Hracek c88b79
 		      (while (string-match (regexp-quote "-") name)
Petr Hracek c88b79
-			(setq name (replace-match "_" nil t name)))
Petr Hracek c88b79
-		      (tramp-maybe-send-script vec (symbol-value rem-dec) name)
Petr Hracek c88b79
+		        (setq name (replace-match "_" nil t name)))
Petr Hracek c88b79
+                (when (string-match "%t" value)
Petr Hracek c88b79
+                    (setq tmpfile
Petr Hracek c88b79
+                         (make-temp-name
Petr Hracek c88b79
+                          (expand-file-name
Petr Hracek c88b79
+                           tramp-temp-name-prefix
Petr Hracek c88b79
+                           (tramp-get-remote-tmpdir vec)))
Petr Hracek c88b79
+                         value
Petr Hracek c88b79
+                         (format-spec
Petr Hracek c88b79
+                          value
Petr Hracek c88b79
+                          (format-spec-make
Petr Hracek c88b79
+                           ?t
Petr Hracek c88b79
+                           (tramp-file-name-handler
Petr Hracek c88b79
+                            'file-remote-p tmpfile 'localname)))))
Petr Hracek c88b79
+                (tramp-maybe-send-script vec value name)
Petr Hracek c88b79
 		      (setq rem-dec name)))
Petr Hracek c88b79
 		  (tramp-message
Petr Hracek c88b79
 		   vec 5