Alexandre Rostovtsev posted on Sat, 25 Aug 2012 17:04:36 -0400 as
excerpted:

> [[ -n "${VALA_API_VERSION}" ]] || die "VALA_API_VERSION not set"

It's just style, but...

1) [[ ]] manages non-word characters (whitespace, etc) hidden behind 
variables, so quotes are only necessary if they appear in string-
literals, not the case here.  I know eliminating the quotes is gentoo 
policy as I've seen it suggested many times before.

2) Gentoo policy regarding implied -n?  I know gentoo policy prefers {} 
cuddled varnames to make the varname explicit, but does it prefer 
explicit -n as well, since that's implicit test behavior and thus does 
not need to be explicitly specified?

To my way of thinking [[ ${var} ]] is even clearer than [[ -n ${var} ]] 
since there's only one way to interpret the former and I have to 
correctly parse the -n (as opposed to -any-other-letter) given the 
latter.  They're even listed together in bash's "help test" output, so 
are considered to have identical behavior to the point of being listed 
together by bash itself.

Incorporating both suggestions:

[[ ${VALA_API_VERSION} ]] || die "VALA_API_VERSION not set"

But regardless of #2, definitely eliminate the quotes inside the [[ ]], 
as I've seen that suggested numerous times in other cases.  The better 
quote handling regarding variables is in fact one of the reasons the 
[[ ]] form is preferred to the POSIX compliant [ ] form.

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman


Reply via email to