Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Stephane Chazelas Newsgroups: gnu.bash.bug Subject: Re: Parameter expansion resulting empty treated as if it's not empty Date: Wed, 30 Oct 2019 17:24:00 +0000 Lines: 29 Approved: bug-bash@gnu.org Message-ID: References: <20191030172400.pom6dbi7afqpzxtu@chaz.gmail.com> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: usenet.stanford.edu 1572456318 23123 209.51.188.17 (30 Oct 2019 17:25:18 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: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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: <20191030172400.pom6dbi7afqpzxtu@chaz.gmail.com> X-Mailman-Original-References: Xref: csiph.com gnu.bash.bug:15540 2019-10-30 14:12:41 +0300, Oğuz: [...] > I was expecting > > bash -c '${1##*"${1##*}"}' _ foo > > to print an empty line too, but instead it prints foo. [...] > Is this a bug? Yes, In gdb, we see the ${1##*} expands to \177 (CTLNUL) as a result of quote_string(). And that's used as is in the outer pattern. It looks like an "unquoting" may be missing in that case. See also: $ bash -c 'printf %s "${2%%"${1##*}"*}"' bash foo $'x\177foo' | hd 00000000 78 |x| 00000001 It seems it's a regression, introduced in 4.0. -- Stephane