[arch-projects] [initscripts] Incorrect environment variable checks in sysinit & co?

Seblu seblu at seblu.net
Thu Mar 31 20:39:37 EDT 2011


On Fri, Apr 1, 2011 at 2:36 AM, Seblu <seblu at seblu.net> wrote:
> On Fri, Apr 1, 2011 at 1:54 AM, Dave Reisner <d at falconindy.com> wrote:
>> On Fri, Apr 01, 2011 at 01:35:18AM +0200, Rémy Oudompheng wrote:
>>> On 2011/4/1 Dave Reisner <d at falconindy.com> 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.
>
Sorry, little mistake in previous one.


-- 
Sébastien Luttringer
www.seblu.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-console-verbosity.patch
Type: text/x-patch
Size: 1069 bytes
Desc: not available
URL: <http://mailman.archlinux.org/pipermail/arch-projects/attachments/20110401/3f1a126e/attachment.bin>


More information about the arch-projects mailing list