[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] ${var:?message} customization
From: |
Dan Douglas |
Subject: |
Re: [Help-bash] ${var:?message} customization |
Date: |
Thu, 14 May 2015 17:30:03 -0500 |
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.
Re: [Help-bash] ${var:?message} customization, Matias A. Fonzo, 2015/05/14
Re: [Help-bash] ${var:?message} customization, Dan Douglas, 2015/05/14