From 486a1b9324d6fc7bc534d8147d64b8b259692c46 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 10 Mar 2011 15:55:02 +0100 Subject: [PATCH] dracut: make options position independent now this is possible: $ dracut test.img -f $ dracut test.img '' -f --- dracut | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/dracut b/dracut index 8553774..e12882d 100755 --- a/dracut +++ b/dracut @@ -111,6 +111,8 @@ read_arg() { fi } +kernel="unset" + while (($# > 0)); do case ${1%%=*} in -m|--modules) read_arg dracutmodules_l "$@" || shift;; @@ -151,10 +153,22 @@ while (($# > 0)); do do_list="yes"; ;; -*) printf "\nUnknown option: %s\n\n" "$1" >&2; usage; exit 1;; - *) break ;; + *) + if ! [[ $outfile ]]; then + outfile=$1 + elif [[ $kernel = "unset" ]]; then + kernel=$1 + else + usage; exit 1; + fi + ;; esac shift done +if ! [[ $kernel ]] || [[ $kernel = "unset" ]]; then + kernel=$(uname -r) +fi +[[ $outfile ]] || outfile="/boot/initramfs-$kernel.img" PATH=/sbin:/bin:/usr/sbin:/usr/bin export PATH @@ -256,8 +270,6 @@ case $dracutmodules in ""|auto) dracutmodules="all" ;; esac -[[ $2 ]] && kernel=$2 || kernel=$(uname -r) -[[ $1 ]] && outfile=$1 || outfile="/boot/initramfs-$kernel.img" abs_outfile=$(readlink -f "$outfile") && outfile="$abs_outfile" srcmods="/lib/modules/$kernel/" -- 2.7.4