Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Bob Proulx 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: Sat, 21 Jul 2018 11:16:17 -0600 Lines: 29 Approved: bug-bash@gnu.org Message-ID: References: <3d5b8d4b-b77e-2486-b45b-ca733e4d0ca0@redhat.com> <20180720223753294160030@bob.proulx.com> <2fe93203-93fd-2a97-ff54-7cb748294640@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: usenet.stanford.edu 1532193387 5522 208.118.235.17 (21 Jul 2018 17:16:27 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: <2fe93203-93fd-2a97-ff54-7cb748294640@case.edu> 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14379 Chet Ramey wrote: > Bob Proulx wrote: > > 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.) > > Even if the whitespace gets stripped out, the quoted null string should > result in an empty argument. Different shells are inconsistent about this, > but I believe that if word splitting occurs, the empty string (or "$e", > anything that expands to an empty string) should result in a null word. Gotcha. Thanks! And further testing confirms the inconsistent shells. bash and ksh both seem to be the outliers in different ways in terms of behavior. dash and zsh seem to be consistent and correct in this. Bob