Re: backtick to NOT set variable

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Wed, 18 May 2016 17:35:16 +0200

On 18/05/2016 13:42, Max Ivanov wrote:
> can backtick (or combination of other scripts commands) can be to NOT
> set env var on error?

  Not if it succeeds.
  However, backtick -i will exit on error: you can use that difference in
program flow to create the sequence you need.


> backtick -n MAYBE_ARG { /bin/false }
> import -u MAYBE_ARG
> s6-echo ${MAYBE_ARG} $_at_

  Note that it's intentional that you always get an argument when
expanding ${MAYBE_ARG}. That's a feature of execline. If you want an
empty ${MAYBE_ARG} to expand to zero word, you need to split the
substitution.


> I could add `-s` flag, to `import` and it solves problem for an empty value,
> but it also splits non empty value which is not desirable.

  Use a splitting delimiter that cannot appear in your value.

-- 
  Laurent
Received on Wed May 18 2016 - 15:35:16 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC