aboutsummaryrefslogtreecommitdiff
path: root/src/connection/shell-wrap.lisp
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-03-04 15:43:06 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-03-04 15:48:02 -0700
commite7d9644ee17d2ab80f19bee07ed775e130c5a645 (patch)
treebc864b38c38d269a14fb5f329849ac54e5386ae0 /src/connection/shell-wrap.lisp
parent7b718e13a18c5672eef909835e53d64bdc934464 (diff)
downloadconsfigurator-e7d9644ee17d2ab80f19bee07ed775e130c5a645.tar.gz
CONNECTION.SHELL-WRAP: error checking in CONNECTION-WRITEFILE
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/connection/shell-wrap.lisp')
-rw-r--r--src/connection/shell-wrap.lisp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/connection/shell-wrap.lisp b/src/connection/shell-wrap.lisp
index 5f94302..99d1735 100644
--- a/src/connection/shell-wrap.lisp
+++ b/src/connection/shell-wrap.lisp
@@ -35,11 +35,18 @@
path
contents
umask)
+ ;; TODO do we want a CONNECTION-ERROR condition?
(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)}"
- nil)))
+ (multiple-value-bind (out exit)
+ (connection-run conn (if umask
+ (format nil "( umask ~O; cat >~A )"
+ umask temp)
+ #?"cat >${temp}")
+ contents)
+ (unless (zerop exit) (error "Failed to write ~A: ~A" temp out)))
+ (multiple-value-bind (out exit)
+ (connection-run
+ conn
+ #?"mv ${(escape-sh-token temp)} ${(escape-sh-token path)}"
+ nil)
+ (unless (zerop exit) (error "Failed to write ~A: ~A" temp out)))))