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


Groups > gnu.bash.bug > #15250 > unrolled thread

T/F var expansion?

Started byL A Walsh <bash@tlinx.org>
First post2019-07-28 21:17 -0700
Last post2019-07-28 21:17 -0700
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#15250 — T/F var expansion?

FromL A Walsh <bash@tlinx.org>
Date2019-07-28 21:17 -0700
SubjectT/F var expansion?
Message-ID<mailman.91.1564373873.1985.bug-bash@gnu.org>
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.




[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web