Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Stephane Chazelas Newsgroups: gnu.bash.bug Subject: Re: T/F var expansion? Date: Mon, 29 Jul 2019 10:28:15 +0100 Lines: 26 Approved: bug-bash@gnu.org Message-ID: References: <5D3E7367.8050308@tlinx.org> <20190729092815.o5ihuawg7rgekqs2@chaz.gmail.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1564401917 10006 209.51.188.17 (29 Jul 2019 12:05:17 GMT) X-Complaints-To: action@cs.stanford.edu To: bug-bash@gnu.org Envelope-to: bug-bash@gnu.org X-Injected-Via-Gmane: http://gmane.org/ User-Agent: NeoMutt/20171215 Content-Disposition: inline In-Reply-To: <5D3E7367.8050308@tlinx.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-Mailman-Approved-At: Mon, 29 Jul 2019 08:05:16 -0400 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <20190729092815.o5ihuawg7rgekqs2@chaz.gmail.com> X-Mailman-Original-References: <5D3E7367.8050308@tlinx.org> Xref: csiph.com gnu.bash.bug:15257 2019-07-28 21:17:43 -0700, L A Walsh: > Is there a T/F var expansion that does: > > var=${tst:+$yes}${tst:-$no} > > but with yes/no in 1 expansion? [...] You can also do: no_yes=(no yes) echo "${no_yes[${var+1}]}" For the reverse: echo "${no_yes[!0${var+1}]}" See also: map=(unset empty non-empty) echo "${map[${var+1}+0${var:+1}]}" -- Stephane