Re: backtick to NOT set variable

From: Max Ivanov <>
Date: Wed, 18 May 2016 17:16:17 +0100

> 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.

I didn't find a construct where rest of the program can be executed in
same process as `backtick`, or at least forked after `backtick`.
Closest I could find is `ifte` with `backtick` as as `progif` and 2
copies of the remaining part of the program in `progif` and `progthen`
which is obviously ugly beyond any limits

>> 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.

Doesn't seem to be true, at least
s6-echo ${NOSUCHVAR} $_at_
is equal to `s6-echo $_at_` if `NOSUCHVAR` is not an environment
variable. As you can see there is no explicit spitting, yet
`${NOSUCHVAR}` is substituted with no argument (not an empty

>> 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.

import -d "\0" -s

gives me a syntax error, anything else is just a magical value and I
am uncomfortable using it.

I can see that problem can be solved neatly with either:

1) introducing alternative to "cmd || :" shell construct, lets call it
`ignoreme` then it would be:
ignoreme backtick -i MAYBEARG { ... }
import -u MAYBEARG
but I can't see how it can be done in a model which execline follows.
It have to be like "foreground" but without a fork which seems not

2) introduce switch to a `backtick` which doesn't set variable on
subprocess error. Here is the patch I just prepared, it is completely
untested, didn't even try to compile yet, but would be happy to hear
feedback on approach

Received on Wed May 18 2016 - 16:16:17 UTC

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