Bugs in defconfig /bin/sh

Denys Vlasenko vda.linux at googlemail.com
Mon Oct 4 23:19:53 UTC 2010


On Tuesday 05 October 2010 01:05, David N. Lombard wrote:
> According to the man page for bash 4.0.38:
>   EXPANSION
>     Expansion is performed on the command line after it has been split
>     into words. There are seven kinds of expansion performed: brace
>     expansion, tilde expansion, parameter and variable expansion,
>     command substitution, arithmetic expansion, word splitting, and
>     pathname expansion.

Well, considering that words themselves are only known after
parameter and variable expansion, the above description
is a bit... "simplified".

>     The order of expansions is: brace expansion, tilde expansion,
>     parameter, variable and arithmetic expansion and command
>     substitution (done in a left-to-right fashion), word splitting,
>     and pathname expansion.
> 
>     On systems that can support it, there is an additional expansion
>     available: process substitution.
> 
>     Only brace expansion, word splitting, and pathname expansion can
>     change the number of words of the expansion; other expansions
>     expand a single word to a single word. The only exceptions to this
>     are the expansions of "$@" and "${name[@]}" as explained above
>     (see PARAMETERS).
> 
> Note variable expansion happens *after" brace expansion.

God, this is worse than I thought!

# va=11; vb=22; echo $v{a,b}
11 22
#

Wow... this will be a bitch to implement...

> So, the 
> outputs you first described (expansion, literal brace/asterisk,
> expansion) are correct.  Bash 2.05b, that didn't expand the braces and
> filenames for the third case, was clearly broken.
> 
> This is consistent with Bourne and Korn, at least back to the early
> '90's when I first started paying very close attention to the shell's
> expanion behavior.

-- 
vda


More information about the busybox mailing list