[pacman-dev] My thoughts for development
Jürgen Hötzel
juergen at hoetzel.info
Wed Dec 20 15:14:22 EST 2006
Hi,
On Wed, Dec 20, 2006 at 01:47:10PM -0600, Aaron Griffin wrote:
> The "x$foo" bash thing is for safety. I can't remember the exact case
> exactly, but it has to do with evaluation of strings when comparing
> (it's one of those things I've just always done)... I'm drawing a
> blank...
I also was surprised by this:
[ "x$NOBUILD" = "1"]
will never be true, because it will always evaluate some thing like
[ "x..." = "1" ]
the safety workaround is only required if you don't double quote (possible
empty) variables. For example:
bash-3.2$ unset EMPTY
bash-3.2$ [ $EMPTY = "" ] && echo empty
bash: [: =: unary operator expected
yes, $EMPTY evaluates to NOTHING, so one operator is missing
bash-3.2$ [ "$EMPTY" = "" ] && echo empty
empty
"$EMPTY" evaluates to an empty string -> OK
bash-3.2$ [ x$EMPTY = x ] && echo empty
empty
uses a fixed prefix as workaround for empty variables.
Jürgen
More information about the pacman-dev
mailing list