On Fri, Apr 1, 2011 at 1:54 AM, Dave Reisner <[email protected]> wrote: > On Fri, Apr 01, 2011 at 01:35:18AM +0200, Rémy Oudompheng wrote: >> On 2011/4/1 Dave Reisner <[email protected]> wrote: >> > 1) Word split /proc/cmdline into an array and use in_array from >> > /etc/rc.d/functions: >> > >> > kern_cmdline=($(< /proc/cmdline)) >> > if in_array "${kern_cmdline[@]}" verbose; then >> > ... >> > >> > 2) Word split /proc/cmdline with printf and use grep -x: >> > >> > if printf "%s\n" $(</proc/cmdline) | grep x 'verbose'; then >> > ... >> > >> >> These look very strange. I would be more tempted to inline the in_array and >> say: >> >> /bin/dmesg -n 3 >> for cmdlinearg >> do >> [[ $cmdlinearg == "verbose" ]] && /bin/dmesg -n 8 >> done >> >> which seems more readable and less magical to me. >> >> Rémy. > > Sure, also valid. It occurred to me that the array isn't actually > necessary, as you can just word split in passing to in_array but > inlining here is fine too. > > one minor nit to pick with the innards of your loop... > > [[ $arg = "verbose" ]] && { /bin/dmesg -n 8; break; } > > dave > > p.s. particularly as of late, I've found that "readable" is highly > subjective, particularly when it comes to Bash. > >
I propose two patches (mutualy exclusive), taking code from dave and remy. PS: Thomas, i (currently) cannot send patch directly from my git. Gonna happen. -- Sébastien Luttringer www.seblu.net
From 86c8f5e7734a8f947ca26c5304ca52b2dd95eda3 Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer <[email protected]> Date: Fri, 1 Apr 2011 02:39:59 +0200 Subject: [initscripts patch] Fix console verbosity To: [email protected] This patch fix verbosity which use var exported by initcpio in place of kernel. Signed-off-by: Sebastien Luttringer <[email protected]> --- rc.conf | 1 + rc.sysinit | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rc.conf b/rc.conf index 02bb1d7..706c194 100644 --- a/rc.conf +++ b/rc.conf @@ -26,6 +26,7 @@ KEYMAP="us" CONSOLEFONT= CONSOLEMAP= USECOLOR="yes" +VERBOSE="no" # ----------------------------------------------------------------------- # HARDWARE diff --git a/rc.sysinit b/rc.sysinit index 9d7c250..5ae3deb 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -31,13 +31,12 @@ fi # start up our mini logger until syslog takes over /sbin/minilogd -# anything more serious than KERN_WARNING goes to the console -# 'verbose' cmdline parameter enables more messages -if [[ -n "$verbose" ]]; then - /bin/dmesg -n 8 -else - /bin/dmesg -n 3 -fi +# Set console verbosity +/bin/dmesg -n 3 +read cmdline < /proc/cmdline +for cmdarg in $cmdline; do + [[ $cmdarg == "verbose" ]] && { /bin/dmesg -n 8; break; } +done HWCLOCK_PARAMS="--hctosys" case $HARDWARECLOCK in -- -- Seblu
From 4b2a4750b078d201ab90b0717af74b7864ba599b Mon Sep 17 00:00:00 2001 From: Sebastien Luttringer <[email protected]> Date: Fri, 1 Apr 2011 02:33:05 +0200 Subject: [initscripts patch] Fix console verbosity and allow config via rc.conf To: [email protected] This patch fix verbosity which use var exported by initcpio in place of kernel. It also include a new variable VERBOSE in rc.conf. Signed-off-by: Sebastien Luttringer <[email protected]> --- rc.conf | 1 + rc.sysinit | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rc.conf b/rc.conf index 02bb1d7..706c194 100644 --- a/rc.conf +++ b/rc.conf @@ -26,6 +26,7 @@ KEYMAP="us" CONSOLEFONT= CONSOLEMAP= USECOLOR="yes" +VERBOSE="no" # ----------------------------------------------------------------------- # HARDWARE diff --git a/rc.sysinit b/rc.sysinit index 9d7c250..162a933 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -31,12 +31,15 @@ fi # start up our mini logger until syslog takes over /sbin/minilogd -# anything more serious than KERN_WARNING goes to the console -# 'verbose' cmdline parameter enables more messages -if [[ -n "$verbose" ]]; then +# Set console verbosity +if [[ $VERBOSE =~ yes|YES ]]; then /bin/dmesg -n 8 else /bin/dmesg -n 3 + read cmdline < /proc/cmdline + for cmdarg in $cmdline; do + [[ $cmdarg == "verbose" ]] && { /bin/dmesg -n 8; break; } + done fi HWCLOCK_PARAMS="--hctosys" -- -- Seblu
