diff options
author | Dave Reisner <d@falconindy.com> | 2011-06-07 02:02:32 +0200 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2011-06-19 23:33:34 +0200 |
commit | 7592c32bda5dc3bc45a98b1ddd91be52963b5be2 (patch) | |
tree | e21fce73e0f6da5be4391fd91d2f766f0d3a1650 /mkinitcpio | |
parent | f2988f2bea65e345fd58e0e413b9eef4359d196b (diff) | |
download | mkinitcpio-7592c32bda5dc3bc45a98b1ddd91be52963b5be2.tar.gz mkinitcpio-7592c32bda5dc3bc45a98b1ddd91be52963b5be2.tar.xz |
mkinitcpio: bashification, part 1/2
Always use bash's [[ ]], and apply (( )) where arithmetic calculations
are made. We also take a few other bash shortcuts to simplify code where
possible.
We also touch the Makefile here to adjust the sed'ing for directory
names.
Signed-off-by: Dave Reisner <d@falconindy.com>
Diffstat (limited to 'mkinitcpio')
-rwxr-xr-x | mkinitcpio | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -118,9 +118,8 @@ while getopts ':c:k:sb:g:p:m:nvH:LMhS:' arg; do cleanup exit 0 ;; L) msg "Available hooks" - for h in ${INSTDIR}/*; do - echo " ${h##*/}" - done + cd "$INSTDIR" >/dev/null + printf ' %s\n' * | column -c$(tput cols) cleanup exit 0 ;; M) SHOW_AUTOMODS=1 ;; @@ -128,7 +127,7 @@ while getopts ':c:k:sb:g:p:m:nvH:LMhS:' arg; do :) echo "${OPTARG} requires a value..."; usage ;; esac done -shift $((${OPTIND} - 1)) +shift $((OPTIND - 1)) if [[ -t 2 ]] && (( COLOR )); then # prefer terminal safe colored and bold text when tput is supported @@ -245,7 +244,7 @@ if (( SHOW_AUTOMODS )); then exit 0 fi -if [ -z "${GENIMG}" ]; then +if [[ -z $GENIMG ]]; then msg "Starting dry run: %s" "$KERNELVERSION" else msg "Starting build: %s" "$KERNELVERSION" @@ -260,7 +259,7 @@ for hook in ${HOOKS}; do # Deprecation check # A hook is considered deprecated if it is a symlink # within $INSTDIR. - if [ -h "${INSTDIR}/${hook}" ]; then + if [[ -h "${INSTDIR}/${hook}" ]]; then newhook="$(readlink -ne "${INSTDIR}/${hook}")" if [ -n "${newhook}" -a "${INSTDIR}/$(get_basename ${newhook})" -ef "${newhook}" ]; then newhook="$(get_basename ${newhook})" @@ -292,9 +291,9 @@ fi declare -i status=0 declare -a pipesave -if [ -n "${GENIMG}" ]; then +if [[ "${GENIMG}" ]]; then msg "Creating $COMPRESSION initcpio image: %s" "$GENIMG" - [ ${COMPRESSION} = "xz" ] && COMPRESSION_OPTIONS="${COMPRESSION_OPTIONS} --check=crc32" + [[ "$COMPRESSION" = xz ]] && COMPRESSION_OPTIONS+=" --check=crc32" pushd "$TMPDIR/root" >/dev/null find . -print0 | bsdcpio -0oH newc | $COMPRESSION $COMPRESSION_OPTIONS > "$IMGPATH" |