[Toybox] Would someone please explain what bash is doing here?

Rob Landley rob at landley.net
Thu Mar 12 09:53:34 PDT 2020


On 3/12/20 9:37 AM, Chet Ramey wrote:
> On 3/11/20 11:55 PM, Rob Landley wrote:
>> Word splitting isn't really a seperate step, exactly? "echo one two three"
>> doesn't care about $IFS, and the output of any of the OTHER substitutions:
> 
> It is, because it operates on the output of the other expansions. Like you
> said, that echo command doesn't undergo word splitting at all.

The relationship between variable expansion, word splitting, and quote removal
is most _politely_ described as "incestuous".

>> And then pathname expansion. Haven't started it yet. I have dirtree and friends,
>> and I wrote my own globbing logic from scratch once back in the 90's. Not too
>> worried about it, just... a bit to chew between here and there.
> 
> Most C libraries have a glob() and fnmatch() you can start with.

I try to use the libc code for stuff when I can because it's smaller and simpler
to _not_ reinvent the wheel, but past a certain delta from the baseline behavior
I switch to not using the libc code at all because then _that's_ smaller (at
least for static builds). The regex stuff is all libc (using the
https://github.com/landley/toybox/commit/48162c4ee3fb extension to support
embedded NUL bytes, which humanity may not live long enough for posix to notice
but eh, or possibly meh). We're not using wordexp() at all. The glob stuff I
don't think toybox is currently using anywhere yet so that decision hasn't been
made...

Either way, I want _one_ implementation of each bit of plumbing with consistent
behavior channeling all the testing through the same codepath.

Rob


More information about the Toybox mailing list