diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2015-06-28 15:48:45 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2015-07-05 16:42:46 +0200 |
commit | 88d6ba6a73921c36865a82259c357419df4b53e4 (patch) | |
tree | aea07ea0e6222490053a288d10fd7727556f497f | |
parent | 17885b0f1a4a8d7ea444426e2dc9c624fe6bb6b2 (diff) |
Minify code in diff-generations command
-rwxr-xr-x | nix-script-diff-generations.sh | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/nix-script-diff-generations.sh b/nix-script-diff-generations.sh index 3a60f15..0721d23 100755 --- a/nix-script-diff-generations.sh +++ b/nix-script-diff-generations.sh @@ -45,12 +45,8 @@ do stdout "Parsing generations: GEN_A: $GEN_A" stdout "Parsing generations: GEN_B: $GEN_B" - if [[ -z "$GEN_A" || -z "$GEN_B" ]] - then - stderr "Parsing error for '$OPTARG'" - usage - exit 1 - fi + [[ -z "$GEN_A" || -z "$GEN_B" ]] && \ + stderr "Parsing error for '$OPTARG'" && usage && exit 1 ;; h) @@ -61,15 +57,8 @@ do done gen_path() { - if [[ $__SYSTEM -eq 1 ]] - then - echo "/nix/var/nix/profiles/system-${1}-link" - fi - - if [[ $__USER -eq 1 ]] - then - echo "/nix/var/nix/profiles/per-user/$USER/profile-${1}-link" - fi + [[ $__SYSTEM -eq 1 ]] && echo "/nix/var/nix/profiles/system-${1}-link" + [[ $__USER -eq 1 ]] && echo "/nix/var/nix/profiles/per-user/$USER/profile-${1}-link" } DIR_A=$(gen_path $GEN_A) @@ -83,23 +72,9 @@ stdout "from directory : $DIR_A" stdout "Generation B : $GEN_B" stdout "from directory : $DIR_B" -if [[ -z "$GEN_A" || -z "$GEN_B" ]] -then - stderr "No generations" - exit 1 -fi - -if [[ ! -e $DIR_A ]] -then - stderr "Generation $GEN_A does not exist." - exit 1 -fi - -if [[ ! -e $DIR_B ]] -then - stderr "Generation $GEN_B does not exist." - exit 1 -fi +[[ -z "$GEN_A" || -z "$GEN_B" ]] && stderr "No generations" && exit 1 +[[ ! -e $DIR_A ]] && stderr "Generation $GEN_A does not exist." && exit 1 +[[ ! -e $DIR_B ]] && stderr "Generation $GEN_B does not exist." && exit 1 versA=$(mktemp) stdout "TMP file '$versA' created" |