]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Fix "--debug" parameter for dracut
authorAndreas Thienemann <andreas@bawue.net>
Wed, 20 May 2009 07:03:01 +0000 (09:03 +0200)
committerHarald Hoyer <harald@redhat.com>
Wed, 20 May 2009 07:03:01 +0000 (09:03 +0200)
remove "-d" as a short-alias for --debug. It collides with the
--driver short-alias.

If --debug is set, inst_script() spews binary "garbage" to the screen
which are interpreted as control characters by the terminal, prompting
the user to call "reset" after dracut has finished. This is related to
set -x  printing binary headers from files to stdout.
As inst_script() is only checking if it is a script it should copy by
reading the first 80chars of the file and checking for the shebang line,
it is safe to call tr on the read in data and remove all unprintable
chars if the debug switch is set.

dracut
dracut-functions

diff --git a/dracut b/dracut
index 109d8e80ea01507376ec7149aabc25fc1f183e65..1aeb0ad8fc4b01ebae4440550442c5b41da24b4a 100755 (executable)
--- a/dracut
+++ b/dracut
@@ -21,7 +21,7 @@ Creates initial ramdisk images for preloading modules
   -d, --drivers [LIST]  Specify a space-separated list of kernel modules to
                          include in the initramfs
   -h, --help            This message
-  -d, --debug           Output debug information of the build process
+  --debug               Output debug information of the build process
   -v, --verbose         Verbose output during the build process
   -c, --conf [FILE]     Specify configuration file to use.
                          Default: /etc/dracut.conf
@@ -43,7 +43,7 @@ while (($# > 0)); do
        -m|--modules) dracutmodules_l="$2"; shift;;
        -d|--drivers) modules_l="$2"; shift;;
        -h|--help) usage; exit 1 ;;
-       -d|--debug) set -x;;
+       --debug) debug="yes"; set -x;;
        -v|--verbose) beverbose="yes";;
        -c|--conf) conffile="$2"; shift;;
        -l|--local) allowlocal="yes" ;;
@@ -96,7 +96,7 @@ hookdirs="pre-udev pre-mount pre-pivot mount"
 readonly initdir=$(mktemp -d -t initramfs.XXXXXX)
 trap 'rm -rf "$initdir"' 0 # clean up after ourselves no matter how we die.
 
-export initdir hookdirs dsrc dracutmodules modules
+export initdir hookdirs dsrc dracutmodules modules debug
 
 # Create some directory structure first
 for d in bin sbin usr/bin usr/sbin usr/lib etc proc sys sysroot dev/pts; do 
index 6839ba9dba2f4ed4194f74aa4876c183d343a4a8..51dd29fa6b229a987fd6ae00db6587c104baff43 100755 (executable)
@@ -127,6 +127,8 @@ inst_script() {
     [[ -f $1 ]] || return 1
     local line
     read -r -n 80 line <"$1"
+    # If debug is set, clean unprintable chars to prevent messing up the term
+    [[ $debug ]] && line=$(echo -n "$line" | tr -c -d '[:print:][:space:]')
     [[ $line =~ (#! *)(/[^ ]+).* ]] || return 1
     inst "${BASH_REMATCH[2]}" && inst_simple "$@"
 }