On Thu, Apr 13, 2023 at 2:25 PM Tomi Ollila <tomi.oll...@iki.fi> wrote:
> On Sun, Apr 09 2023, David Bremner wrote:

> I would just use [ "${VAR-}" = 1 ] in shell script code (or barely
> [[ ${VAR-0} == 1 ]] if desired not to have ""s around variables...but...)
>
> ... using [ "${VAR-}" = 1 ] is also good in a sense that someone may
> use it as an example to write shell scripts with #!/bin/sh as a
> hashbang -- and it works fine on Fedora since there /bin/sh is bash,
> but would fail on Debian since there /bin/sh is dash.

Yeah, the world of shells is a universe, but long story short: you can
just use the above and it should work on all shells and all
configurations.

You can just do "$VAR", *but* it wouldn't work with `set -u`. I never
use -u, so I don't care, but if you do care, do "${VAR-}".

Cheers.

-- 
Felipe Contreras
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-le...@notmuchmail.org

Reply via email to