rc.d standardization patch

Oliver Fromme check+j3df9e00rshfwkvl at fromme.com
Wed Aug 2 05:58:35 PDT 2006

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\"


    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 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.

More information about the Submit mailing list