[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Empty ""s in ARG in ${x:+ARG} expand to no words instead of the empt
From: |
Bob Proulx |
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 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
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