nixos-rebuild: Use ‘[ ... ]’ instead of ‘test’

This commit is contained in:
Eelco Dolstra 2013-01-16 13:21:59 +01:00
parent 4d983d4955
commit ea358b4eae
1 changed files with 12 additions and 12 deletions

View File

@ -50,7 +50,7 @@ buildNix=1
rollback=
upgrade=
while test "$#" -gt 0; do
while [ "$#" -gt 0 ]; do
i="$1"; shift 1
case "$i" in
--help)
@ -94,13 +94,13 @@ while test "$#" -gt 0; do
esac
done
if test -z "$action"; then showSyntax; fi
if [ -z "$action" ]; then showSyntax; fi
if test "$action" = dry-run; then
if [ "$action" = dry-run ]; then
extraBuildFlags+=(--dry-run)
fi
if test -n "$rollback"; then
if [ -n "$rollback" ]; then
buildNix=
fi
@ -143,12 +143,12 @@ fi
# Either upgrade the configuration in the system profile (for "switch"
# or "boot"), or just build it and create a symlink "result" in the
# current directory (for "build" and "test").
if test -z "$rollback"; then
if [ -z "$rollback" ]; then
echo "building the system configuration..." >&2
if test "$action" = switch -o "$action" = boot; then
if [ "$action" = switch -o "$action" = boot ]; then
nix-env "${extraBuildFlags[@]}" -p /nix/var/nix/profiles/system -f '<nixos>' --set -A system
pathToConfig=/nix/var/nix/profiles/system
elif test "$action" = test -o "$action" = build -o "$action" = dry-run; then
elif [ "$action" = test -o "$action" = build -o "$action" = dry-run ]; then
nix-build '<nixos>' -A system -K -k "${extraBuildFlags[@]}" > /dev/null
pathToConfig=./result
elif [ "$action" = build-vm ]; then
@ -160,11 +160,11 @@ if test -z "$rollback"; then
else
showSyntax
fi
else # test -n "$rollback"
if test "$action" = switch -o "$action" = boot; then
else # [ -n "$rollback" ]
if [ "$action" = switch -o "$action" = boot ]; then
nix-env --rollback -p /nix/var/nix/profiles/system
pathToConfig=/nix/var/nix/profiles/system
elif test "$action" = test -o "$action" = build; then
elif [ "$action" = test -o "$action" = build ]; then
systemNumber=$(
nix-env -p /nix/var/nix/profiles/system --list-generations |
sed -n '/current/ {g; p;}; s/ *\([0-9]*\).*/\1/; h'
@ -179,7 +179,7 @@ fi
# If we're not just building, then make the new configuration the boot
# default and/or activate it now.
if test "$action" = switch -o "$action" = boot -o "$action" = test; then
if [ "$action" = switch -o "$action" = boot -o "$action" = test ]; then
# Just in case the new configuration hangs the system, do a sync now.
sync
@ -187,7 +187,7 @@ if test "$action" = switch -o "$action" = boot -o "$action" = test; then
fi
if test "$action" = build-vm; then
if [ "$action" = build-vm ]; then
cat >&2 <<EOF
Done. The virtual machine can be started by running $(echo $pathToConfig/bin/run-*-vm).