Commit
* properly expand the command using arrays instead of strings * also handle sudo on the localhost
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ repair= | |
profile=/nix/var/nix/profiles/system | ||
buildHost= | ||
targetHost= | ||
maybeSudo= | ||
maybeSudo=() | ||
|
||
while [ "$#" -gt 0 ]; do | ||
i="$1"; shift 1 | ||
|
@@ -92,7 +92,7 @@ while [ "$#" -gt 0 ]; do | |
;; | ||
--use-remote-sudo) | ||
# note the trailing space | ||
This comment has been minimized.
Sorry, something went wrong. |
||
maybeSudo="sudo " | ||
maybeSudo=(sudo --) | ||
shift 1 | ||
;; | ||
*) | ||
|
@@ -102,6 +102,10 @@ while [ "$#" -gt 0 ]; do | |
esac | ||
done | ||
|
||
if [ -n "$SUDO_USER" ]; then | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bjornfor
Contributor
|
||
maybeSudo=(sudo --) | ||
fi | ||
|
||
if [ -z "$buildHost" -a -n "$targetHost" ]; then | ||
buildHost="$targetHost" | ||
fi | ||
|
@@ -116,17 +120,17 @@ buildHostCmd() { | |
if [ -z "$buildHost" ]; then | ||
"$@" | ||
elif [ -n "$remoteNix" ]; then | ||
ssh $SSHOPTS "$buildHost" env PATH="$remoteNix:$PATH" "$maybeSudo$@" | ||
ssh $SSHOPTS "$buildHost" env PATH="$remoteNix:$PATH" "${maybeSudo[@]}" "$@" | ||
else | ||
ssh $SSHOPTS "$buildHost" "$maybeSudo$@" | ||
ssh $SSHOPTS "$buildHost" "${maybeSudo[@]}" "$@" | ||
fi | ||
} | ||
|
||
targetHostCmd() { | ||
if [ -z "$targetHost" ]; then | ||
"$@" | ||
"${maybeSudo[@]}" "$@" | ||
else | ||
ssh $SSHOPTS "$targetHost" "$maybeSudo$@" | ||
ssh $SSHOPTS "$targetHost" "${maybeSudo[@]}" "$@" | ||
fi | ||
} | ||
|
||
|
Comment doesn't apply anymore.