Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15250

T/F var expansion?

From L A Walsh <bash@tlinx.org>
Newsgroups gnu.bash.bug
Subject T/F var expansion?
Date 2019-07-28 21:17 -0700
Message-ID <mailman.91.1564373873.1985.bug-bash@gnu.org> (permalink)
References <5D3E7367.8050308@tlinx.org>

Show all headers | View raw


Is there a T/F var expansion that does:
 
    var=${tst:+$yes}${tst:-$no}

but with yes/no in 1 expansion?

Something like:

    var=${tst:^yes^no}
              |   |
              \___\___ or some other char(s)

    with the opposite syntax being allowed as

    var=${!tst:^no^yes}

(or) if '!' before the varname is unwieldy:

     var=${tst:!no!yes}

----
Obviously the 1 code-snippet solves the problem, but looks
a bit redundant, at the least...

Sorry if this is already implemented in some form, I'm just
not remembering there being one.




Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

T/F var expansion? L A Walsh <bash@tlinx.org> - 2019-07-28 21:17 -0700

csiph-web