diff options
author | Dave Reisner <d@falconindy.com> | 2011-06-07 01:09:40 +0200 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2011-06-16 22:16:47 +0200 |
commit | fae6f29b149e343bd638e67f25a6a1001ca37fb0 (patch) | |
tree | 33c3e99abd0a78eb4b857cc9528a7d709b74195f | |
parent | 28b191ea76efc0f8c39bc9159cdc10b72ddf8740 (diff) | |
download | mkinitcpio-fae6f29b149e343bd638e67f25a6a1001ca37fb0.tar.gz mkinitcpio-fae6f29b149e343bd638e67f25a6a1001ca37fb0.tar.xz |
declare SAVELIST, QUIET, SHOW_AUTOMODS as faux booleans
Signed-off-by: Dave Reisner <d@falconindy.com>
-rw-r--r-- | functions | 2 | ||||
-rwxr-xr-x | mkinitcpio | 17 |
2 files changed, 9 insertions, 10 deletions
@@ -1,6 +1,6 @@ #!/bin/bash -msg () { [ "${QUIET}" = "n" ] && echo $@; } +msg () { (( QUIET )) || echo $@; } err () { echo "ERROR: $@" >&2; } die () { echo "FATAL: $@" >&2; cleanup; exit 1; } @@ -21,11 +21,10 @@ CONFIG=mkinitcpio.conf HOOKDIR=hooks INSTDIR=install PRESETDIR=mkinitcpio.d -QUIET=y -SHOW_AUTOMODS=n COMPRESSION=gzip -declare BASEDIR MODULE_FILE SAVELIST GENIMG PRESET MESSAGE COMPRESSION_OPTIONS +declare BASEDIR MODULE_FILE GENIMG PRESET MESSAGE COMPRESSION_OPTIONS +declare -i QUIET=1 SHOW_AUTOMODS=0 SAVELIST=0 declare -a SKIPHOOKS ADDED_MODULES # Add /{,usr}/sbin to path @@ -59,7 +58,7 @@ usage () cleanup () { - if [[ $SAVELIST ]]; then + if (( SAVELIST )); then echo ":: build directory saved in $TMPDIR" else rm -rf ${TMPDIR} @@ -101,12 +100,12 @@ while getopts ':c:k:sb:g:p:m:vH:LMhS:' arg; do case "${arg}" in c) CONFIG="${OPTARG}" ;; k) optkver=$OPTARG ;; - s) SAVELIST="y"; ;; + s) SAVELIST=1; ;; b) BASEDIR="${OPTARG}" ;; g) GENIMG="${OPTARG}" ;; p) PRESET="${OPTARG}" ;; m) MESSAGE="${OPTARG}" ;; - v) QUIET="n" ;; + v) QUIET=0 ;; S) OLDIFS=${IFS} IFS=, SKIPHOOKS=(${OPTARG}) @@ -124,7 +123,7 @@ while getopts ':c:k:sb:g:p:m:vH:LMhS:' arg; do done cleanup exit 0 ;; - M) SHOW_AUTOMODS="y" ;; + M) SHOW_AUTOMODS=1 ;; h|?) usage ;; :) echo "${OPTARG} requires a value..."; usage ;; *) echo "invalid argument '${arg}'"; usage ;; @@ -147,7 +146,7 @@ if [[ $PRESET ]]; then declare -a preset_mkopts preset_cmd [[ $BASEDIR ]] && preset_mkopts+=(-b "$BASEDIR") [[ $MESSAGE ]] && preset_mkopts+=(-m "$MESSAGE") - [[ "$QUIET" = n ]] && preset_mkopts+=(-v) + (( QUIET )) || preset_mkopts+=(-v) # Build all images . "$PRESETDIR/$PRESET.preset" for p in "${PRESETS[@]}"; do @@ -236,7 +235,7 @@ fi . "$FUNCTIONS" -if [ "${SHOW_AUTOMODS}" = "y" ]; then +if (( SHOW_AUTOMODS )); then echo "Modules autodetected:" . "${INSTDIR}/autodetect" build |