On Thu, May 14, 2015 at 8:06 AM, Eric Blake <address@hidden> wrote:
> By the way, this test can be portably shortened to:
>
> if [ ${var+y} ]; then
This has always seemed convoluted to me. Testing whether a variable is
set, only to expand a string and copy its value so another command can
test the length and get an answer as a side-effect. The simplest and
fastest POSIX methods are:
! ${var+false}
${var+:} false
Particularly the former since no command is executed at all in the
unset case, though the latter has the advantage of being
bourne-compatible.