nixos-rebuild: Avoid empty command
"${a[@]}" => ok "${foo:+a[@]}" => empty string when length is 0
This commit is contained in:
parent
472dfb3888
commit
c8c3c5854e
1 changed files with 19 additions and 5 deletions
|
@ -177,20 +177,34 @@ runCmd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
buildHostCmd() {
|
buildHostCmd() {
|
||||||
|
local c
|
||||||
|
if [[ "${useSudo:-x}" = 1 ]]; then
|
||||||
|
c=("${sudoCommand[@]}")
|
||||||
|
else
|
||||||
|
c=()
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$buildHost" ]; then
|
if [ -z "$buildHost" ]; then
|
||||||
runCmd "$@"
|
runCmd "$@"
|
||||||
elif [ -n "$remoteNix" ]; then
|
elif [ -n "$remoteNix" ]; then
|
||||||
runCmd ssh $SSHOPTS "$buildHost" "${useSudo:+${sudoCommand[@]}}" env PATH="$remoteNix":'$PATH' "$@"
|
runCmd ssh $SSHOPTS "$buildHost" "${c[@]}" env PATH="$remoteNix":'$PATH' "$@"
|
||||||
else
|
else
|
||||||
runCmd ssh $SSHOPTS "$buildHost" "${useSudo:+${sudoCommand[@]}}" "$@"
|
runCmd ssh $SSHOPTS "$buildHost" "${c[@]}" "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
targetHostCmd() {
|
targetHostCmd() {
|
||||||
if [ -z "$targetHost" ]; then
|
local c
|
||||||
runCmd "${useSudo:+${sudoCommand[@]}}" "$@"
|
if [[ "${useSudo:-x}" = 1 ]]; then
|
||||||
|
c=("${sudoCommand[@]}")
|
||||||
else
|
else
|
||||||
runCmd ssh $SSHOPTS "$targetHost" "${useSudo:+${sudoCommand[@]}}" "$@"
|
c=()
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$targetHost" ]; then
|
||||||
|
runCmd "${c[@]}" "$@"
|
||||||
|
else
|
||||||
|
runCmd ssh $SSHOPTS "$targetHost" "${c[@]}" "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue