[BusyBox] Re: environment variables that are set in the boot eeprom not set in shell environment

Robert P. J. Day rpjday at mindspring.com
Sat Jun 25 16:30:12 UTC 2005


On Fri, 24 Jun 2005, Wolfgang Denk wrote:

> In message <42BC263B.6050007 at ll.mit.edu> you wrote:
> > Got the solution:
> > hseTargetName=`cat /proc/cmdline | sed 's/.*hseTargetName=//'|sed 's/ .*//'`
>
> Useless use of 'cat' award pending. And another useless sed process.
> 67% overhead.
>
> Why not simply:
>
> 	sed -e 's/.*hseTargetName=//' -e 's/ .*//' /proc/cmdline

i'll see you one unnecessary sed, and raise you a much faster expr.
given a string containing "var=value" in it somewhere, you can extract
that value with

  expr "$string" : ".*var=\([^ ]*\)"

IMHO, the "expr" command is sadly overlooked for simple pattern
matching and extraction.  and, in many shells, it's built in so it
should be smokin' fast.

rday



More information about the busybox mailing list