aboutsummaryrefslogtreecommitdiff
path: root/src/connection.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-02-27 09:44:26 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-02-27 13:39:57 -0700
commit4f3672536a9c96476aa5576beeeb446086ef64e7 (patch)
tree208837cd6cc6551ea362c1e7a2ef9d94e8e76bb7 /src/connection.lisp
parent838d7aac806e2ebd8f2971c8774598f688191a9a (diff)
downloadconsfigurator-4f3672536a9c96476aa5576beeeb446086ef64e7.tar.gz
fix :SHELL-WRAP's CONNECTION-WRITEFILE
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection.lisp')
-rw-r--r--src/connection.lisp23
1 files changed, 12 insertions, 11 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)