Also make sure that simple variables are declared as null strings. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 12 +++++++++--- mkinitcpio | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/functions b/functions index 7f9202f..64a1d17 100644 --- a/functions +++ b/functions @@ -115,6 +115,8 @@ _add_symlink() { auto_modules() { # Perform auto detection of modules via sysfs. + local mods= + IFS=$'\n' read -rd '' -a mods < \ <(find /sys/devices -name modalias -exec sort -u {} + | xargs -d $'\n' modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" | @@ -129,6 +131,8 @@ all_modules() { # $@: filter arguments to grep local -i count=0 + local mod= + while read -r -d '' mod; do (( ++count )) mod=${mod##*/} @@ -157,7 +161,7 @@ add_module() { # discovered and added. # $1: module name - local module path dep deps field value + local module= path= dep= deps= field= value= local -i ign_errors=0 if [[ $1 = -@(t|-try) ]]; then @@ -213,6 +217,8 @@ add_full_dir() { # No parsing is performed and the contents of the directory is added as is. # $1: path to directory + local f= + if [[ -n $1 && -d $1 ]]; then for f in "$1"/*; do if [[ -d "$f" ]]; then @@ -277,7 +283,7 @@ add_binary() { # $2: destination on initcpio (optional, defaults to same as source) local -a sodeps - local regex binary dest mode sodep resolved dirname + local line= regex= binary= dest= mode= sodep= resolved= dirname= if [[ ${1:0:1} != '/' ]]; then binary=$(pathlookup "$1") @@ -321,7 +327,7 @@ parse_hook() { # prior to the start of hook processing, and after each hook's build # function is run. - local item + local item= for item in $MODULES; do if [[ ${item:(-1)} = '?' ]]; then diff --git a/mkinitcpio b/mkinitcpio index 49dabbd..82faaaf 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -21,7 +21,7 @@ INSTDIR=install PRESETDIR=mkinitcpio.d COMPRESSION=gzip -declare TMPDIR BASEDIR MODULE_FILE GENIMG PRESET COMPRESSION_OPTIONS BUILDROOT +declare TMPDIR= BASEDIR= MODULE_FILE= GENIMG= PRESET= COMPRESSION_OPTIONS= BUILDROOT= declare NC= BOLD= BLUE= GREEN= RED= YELLOW= declare -i QUIET=1 SHOW_AUTOMODS=0 SAVELIST=0 COLOR=1 declare -a SKIPHOOKS ADDED_MODULES MODPATHS @@ -74,7 +74,7 @@ cleanup () } get_kernver() { - local kernel=$1 + local kernver= kernel=$1 if [[ "${kernel:0:1}" != / ]]; then echo $kernel -- 1.7.6.4