summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2015-06-28 15:54:34 +0200
committerMatthias Beyer <mail@beyermatthias.de>2015-07-05 16:48:12 +0200
commit98c96a44ec4173e8032a69c2c5ad93e7c9ee44fc (patch)
tree3e225de16ccdd432c3bf2ea10966c40a8115e1c6
parent997abf3fd1b0e3618f7676ed40b4f8dc83d296ee (diff)
Minify code in switch command
-rwxr-xr-xnix-script-switch.sh34
1 files changed, 8 insertions, 26 deletions
diff --git a/nix-script-switch.sh b/nix-script-switch.sh
index 4768f1e..9b25614 100755
--- a/nix-script-switch.sh
+++ b/nix-script-switch.sh
@@ -69,28 +69,13 @@ done
ARGS=$(echo $* | sed -r 's/(.*)(\-\-(.*)|$)/\2/')
stdout "ARGS = $ARGS"
-if [[ -z "$WD" ]]
-then
- stderr "No configuration git directory."
- stderr "Won't do anything"
- exit 1
-fi
-
-if [[ ! -d "$WD" ]]
-then
- stderr "No directory: $WD"
- exit 1
-fi
+[[ -z "$WD" ]] && \
+ stderr "No configuration git directory." && \
+ stderr "Won't do anything" && exit 1
-if [[ -z "$COMMAND" ]]
-then
- COMMAND="switch"
-fi
-
-if [[ -z "$GIT_COMMAND" ]]
-then
- GIT_COMMAND="tag -a"
-fi
+[[ ! -d "$WD" ]] && stderr "No directory: $WD" && exit 1
+[[ -z "$COMMAND" ]] && COMMAND="switch"
+[[ -z "$GIT_COMMAND" ]] && GIT_COMMAND="tag -a"
explain sudo nixos-rebuild $COMMAND $ARGS
REBUILD_EXIT=$?
@@ -102,11 +87,8 @@ then
if [[ -z "$TAG_NAME" ]]
then
- if [[ -z "$HOSTNAME" ]]
- then
- TAG_NAME="nixos-$LASTGEN-$COMMAND"
- else
- TAG_NAME="nixos-$HOSTNAME-$LASTGEN-$COMMAND"
+ if [[ -z "$HOSTNAME" ]]; then TAG_NAME="nixos-$LASTGEN-$COMMAND"
+ else TAG_NAME="nixos-$HOSTNAME-$LASTGEN-$COMMAND"
fi
fi