DragonFly BSD
DragonFly submit List (threaded) for 2006-08
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: rc.d standardization patch


From: Oliver Fromme <check+j3df9e00rshfwkvl@xxxxxxxxxx>
Date: 02 Aug 2006 12:58:35 GMT

Kevin L. Kane wrote:
 > Simon 'corecode' Schubert wrote:
 > > Kevin L. Kane wrote:
 > > > [...]
 > > > +     eval _value=\$${1}_enable
 > > [...]
 > >      eval \$${1}=\$${1}_enable
 > [...]
 > I just updated patch with a simplified block along the lines you said.
 > except:
 > eval ${1}=$_value

You have to be very careful with "eval" in shell scripts.
It is best to always escape dollar signs on the right, so
they're expanded on the second pass, not on the first, and
enclose the whole expression in escaped double quotes:

    eval $1=\"\$_value\"

or:

    eval $1='"$_value"'

That's the _only_ way that will always work if the value
of the variable contains white space, semicolons or other
nasty things.  If the value comes from a configuration file
and hasn't be checked for errors, then you cannot guarantee
that it's "clean".  You probably don't want your rc scripts
abort due to a shell syntax error during boot just because
you accidentally inserted a space in one of the variables.
;-)

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd

Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]