aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/connection.lisp23
-rw-r--r--src/connection/shell-wrap.lisp9
2 files changed, 16 insertions, 16 deletions
diff --git a/src/connection.lisp b/src/connection.lisp
index 47356c0..b33d814 100644
--- a/src/connection.lisp
+++ b/src/connection.lisp
@@ -145,16 +145,17 @@ the root Lisp's machine. For example, using rsync(1) over SSH."))
(stderr :initarg :stderr :reader failed-stderr)
(exit-code :initarg :exit-code :reader failed-exit-code)))
-(defmacro with-remote-temporary-file ((file) &body body)
- `(let ((,file (mktemp)))
- (unwind-protect
- (progn ,@body)
- (connection-run *connection*
- (format nil "rm -f ~A"
- (escape-sh-token ,file))
- nil))))
-
-(defun mktemp ()
+(defmacro with-remote-temporary-file ((file &key (connection '*connection*))
+ &body body)
+ (once-only (connection)
+ `(let ((,file (mktemp ,connection)))
+ (unwind-protect
+ (progn ,@body)
+ (connection-run ,connection
+ (format nil "rm -f ~A" (escape-sh-token ,file))
+ nil)))))
+
+(defun mktemp (&optional (connection *connection*))
"Make a temporary file on the remote side."
(multiple-value-bind (out exit)
;; mktemp(1) is not POSIX; the only POSIX way is this m4 way,
@@ -162,7 +163,7 @@ the root Lisp's machine. For example, using rsync(1) over SSH."))
;; often be absent, so have a fallback. Avoid passing any arguments to
;; mktemp(1) as these may differ on different platforms.
(connection-run
- *connection*
+ connection
"echo 'mkstemp('${TMPDIR:-/tmp}'/tmp.XXXXXX)' | m4 2>/dev/null || mktemp"
nil)
(if (= exit 0)
diff --git a/src/connection/shell-wrap.lisp b/src/connection/shell-wrap.lisp
index 70d094c..9619cc1 100644
--- a/src/connection/shell-wrap.lisp
+++ b/src/connection/shell-wrap.lisp
@@ -35,11 +35,10 @@
path
contents
umask)
- (with-remote-temporary-file (temp)
- (connection-run conn
- (if umask
- (format nil "( umask ~O; cat >~A )" umask temp)
- #?"cat >${temp}")
+ (with-remote-temporary-file (temp :connection conn)
+ (connection-run conn (if umask
+ (format nil "( umask ~O; cat >~A )" umask temp)
+ #?"cat >${temp}")
contents)
(connection-run conn
#?"mv ${(escape-sh-token temp)} ${(escape-sh-token path)}"