[Bug 3091] Nonportable tool usage in scripts

Rich Felker dalias at aerifal.cx
Wed Feb 9 05:23:51 UTC 2011


On Wed, Feb 09, 2011 at 01:33:28AM +0100, Denys Vlasenko wrote:
> > Oh, sorry. In scripts/mkconfigs, there are two occurrances of:
> > 
> > grep '^#\? \?CONFIG_' "$config" \
> > 
> > they should read:
> > 
> > egrep '^#? ?CONFIG_' "$config" \
> 
> I see that this '?' thing is a can of worms.
> I propose to sidestep it entirely:
> 
> --- a/scripts/mkconfigs
> +++ b/scripts/mkconfigs
> @@ -42,7 +42,7 @@ echo "\
>   */
>  static const char bbconfig_config[] ALIGN1 ="
> 
> -grep '^#\? \?CONFIG_' "$config" \
> +grep -e '^# CONFIG_' -e '^CONFIG_' "$config" \
>  | sed -e 's/\"/\\\"/g' -e 's/^/"/' -e 's/$/\\n"/'

I have no objection to doing it this way, but if the user has edited
the config file by hand, isn't it very possible you'll find #CONFIG_
with no space? Of course there are a lot of other ways a user might
format modified lines which the existing regex does not account for.

My vote would be to commit either fix (mine or yours) as you see fit,
and worry later about whether to improve the script to handle
different formatting.

Rich


More information about the busybox mailing list