Also make sure that simple variables are declared as null strings.
Signed-off-by: Dave Reisner
---
functions | 12 +++++++++---
mkinitcpio | 4 ++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/functions b/functions
index c7e167e..69a4aad 100644
--- a/functions
+++ b/functions
@@ -94,6 +94,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 modprobe -d "$BASEDIR" -aRS "$KERNELVERSION" |
@@ -108,6 +110,8 @@ all_modules() {
# $@: filter arguments to grep
local -i count=0
+ local mod=
+
while read -r -d '' mod; do
(( ++count ))
mod=${mod##*/}
@@ -136,7 +140,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
@@ -192,6 +196,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
@@ -256,7 +262,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=
binary=$BASEDIR$1
@@ -296,7 +302,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