From: Will Woods Date: Mon, 16 May 2011 23:17:57 +0000 (-0400) Subject: Fix "can't shift that many" crash with empty /proc/cmdline X-Git-Tag: 011~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7573ac58f2febadae9cd03b1043d52265d2523e9;p=thirdparty%2Fdracut.git Fix "can't shift that many" crash with empty /proc/cmdline If /proc/cmdline is empty (like if root=... is set in /etc/cmdline), modules.d/99base/init will crash with a message saying "can't shift that many" right before switch_root. The problem is in the block of code that tries to look for init args. It does something like: read CMDLINE : corrected commit message] [Harald Hoyer : fixed indention] Signed-off-by: Will Woods --- diff --git a/modules.d/99base/init b/modules.d/99base/init index e2c34c725..83085028c 100755 --- a/modules.d/99base/init +++ b/modules.d/99base/init @@ -361,19 +361,18 @@ if getarg init= >/dev/null ; then ignoreargs="console BOOT_IMAGE" # only pass arguments after init= to the init CLINE=${CLINE#*init=} - set $CLINE - shift - for x in "$@"; do - for s in $ignoreargs; do - [ "${x%%=*}" = $s ] && continue 2 - done - initargs="$initargs $x" + set -- $CLINE + shift # clear out the rest of the "init=" arg + for x in "$@"; do + for s in $ignoreargs; do + [ "${x%%=*}" = $s ] && continue 2 done - unset CLINE + initargs="$initargs $x" + done + unset CLINE else set +x # Turn off debugging for this section - set $CLINE - shift + set -- $CLINE for x in "$@"; do case "$x" in [0-9]|s|S|single|emergency|auto ) \