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


Groups > gnu.bash.bug > #14375

Re: Empty ""s in ARG in ${x:+ARG} expand to no words instead of the empty word if prepended/appended with space

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Bob Proulx <bob@proulx.com>
Newsgroups gnu.bash.bug
Subject Re: Empty ""s in ARG in ${x:+ARG} expand to no words instead of the empty word if prepended/appended with space
Date Fri, 20 Jul 2018 22:44:10 -0600
Lines 24
Approved bug-bash@gnu.org
Message-ID <mailman.3946.1532148258.1292.bug-bash@gnu.org> (permalink)
References <3d5b8d4b-b77e-2486-b45b-ca733e4d0ca0@redhat.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1532148258 13129 208.118.235.17 (21 Jul 2018 04:44:18 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
Mail-Followup-To bug-bash@gnu.org
Content-Disposition inline
In-Reply-To <3d5b8d4b-b77e-2486-b45b-ca733e4d0ca0@redhat.com>
User-Agent Mutt/1.10.1 (2018-07-13)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy]
X-Received-From 96.88.95.61
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
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 <http://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>
Xref csiph.com gnu.bash.bug:14375

Show key headers only | View raw


Denys Vlasenko wrote:
> $ f() { for i; do echo "|$i|"; done; }
> $ x=x
> $ e=
> $ f ${x:+ ""}
> ^^^^^^^^^^^ prints nothing, bug?
> 
> $  ${x:+"" }
> ^^^^^^^^^^^ prints nothing, bug?

Insufficient quoting.  That argument should be quoted to avoid the
whitespace getting stripped.  (Is that during word splitting phase
using the IFS?  I think so.)

Try this:

  f "${x:+ ""}"
  f "${x:+"" }"

Also in the future please say what version of bash you are using.
There have been a lot of bugs fixed in various versions.

Bob

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


Thread

Re: Empty ""s in ARG in ${x:+ARG} expand to no words instead of the empty word if prepended/appended with space Bob Proulx <bob@proulx.com> - 2018-07-20 22:44 -0600

csiph-web