hush: add support for #/% parameter substitution

Denys Vlasenko vda.linux at googlemail.com
Thu Apr 9 01:10:19 UTC 2009


On Monday 06 April 2009 08:24, Mike Frysinger wrote:
> this code is based on the stuff in ash.  i started to go the route of the math 
> code and split it out into a library to share code, but after getting my head 
> around the ash interface, i found the implementation sucks in that:
>  - it's tied to the ash parser in terms of variable meaning
>  - the pattern must follow the variable contents in memory
> 	i.e. "foo=aba; echo ${foo#a*};" creates "aba\0a*"
>  - the functions (unnecessarily imo) rely on ash's method for escaping chars
> 
> as such, i split out the scanleft and scanright funcs into shell/match.c and 
> then simplified them greatly to follow a more natural form based on what the 
> functions are doing: matching a pattern against a string.  however, i did not 
> go back and try to merge things back with the ash shell.  i'm not terribly 
> concerned there.
> 
> the attached diff allows hush to pass ash's posix tests for these forms (btw, 
> we should probably look at trying to unify these test trees ...).  while the 
> hunk against hush.c looks like i didnt indent code in expand_vars_to_list, i 
> actually did, but i generated the diff with -w to make it more readable.  
> indenting the expansion block added noise and makes it harder to digest the 
> changes.

Thanks!
--
vda


More information about the busybox mailing list