[arch-projects] [mkinitcpio] [RFC] Rewrite parse_cmdline (again)

Thomas Bächler thomas at archlinux.org
Thu Apr 14 17:28:11 EDT 2011

Am 14.04.2011 23:09, schrieb Dave Reisner:
>> I tested it better than 0.6.10 and it seems okay. Can
>> someone please proof-read this and tell me if it is
>> good?
> Sandbox testing says this doesn't work. I feed in a file containing:
>   root=/dev/sda video="din:10 foo bar baz" quiet ro
> and after parsing, i echo "root=$root" and "video=$video". i get...
>   video="din:10 foo bar baz
>   root=/dev/sda

Oh yeah, I forgot one line, fixed it (I'll send a v2 in a second).

> I posted what I thought was a valid solution on FS#23467 from stack
> overflow that seems to be a lot more sane and _much_ more maintainable.
> For those who weren't following the report, I suggested that we use the
> same fallback as /etc/fstab, which says to encode spaces with octal
> sequences. These can then be decoded using printf's %b flag. It requires
> only a simple change to the current parse_cmdline function.

I really don't understand what you mean (or how it would help). What you
mentioned doesn't solve the initial problem of finding out which spaces
separate arguments and which spaces are inside quoted strings.

> I also never got a response as to where you're seeing pollution from
> using export over eval.

'export' exports variables to the environment and they are passed on
when forking. These variables are for internal purposes in mkinitcpio
and don't belong into other applications. As a simple example, I had
'udevd_running=1' set in my environment during initscripts, which
certainly shouldn't be there. (This wasn't on the command line, but in
another place in mkinitcpio where things where exported when they
shouldn't be).

The right way would be something like bash's 'declare', but ash doesn't
have that.

> Sorry, but eval sucks hard and I've put a lot of
> effort into _removing_ it from wherever I can in Arch code. It's
> _rarely_ used properly.

If you check carefully, I use eval right here. There is nothing in the
eval'ed strings that should cause trouble.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/arch-projects/attachments/20110414/5f332898/attachment.asc>

More information about the arch-projects mailing list