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


Groups > gnu.bash.bug > #15250

T/F var expansion?

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From L A Walsh <bash@tlinx.org>
Newsgroups gnu.bash.bug
Subject T/F var expansion?
Date Sun, 28 Jul 2019 21:17:43 -0700
Lines 31
Approved bug-bash@gnu.org
Message-ID <mailman.91.1564373873.1985.bug-bash@gnu.org> (permalink)
References <5D3E7367.8050308@tlinx.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1564373873 27248 209.51.188.17 (29 Jul 2019 04:17:53 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
User-Agent Thunderbird
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic]
X-Received-From 173.164.175.65
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <5D3E7367.8050308@tlinx.org>
Xref csiph.com gnu.bash.bug:15250

Show key headers only | 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