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


Groups > gnu.bash.bug > #15540

Re: Parameter expansion resulting empty treated as if it's not empty

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Stephane Chazelas <stephane.chazelas@gmail.com>
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 <mailman.1.1572456318.3687.bug-bash@gnu.org> (permalink)
References <CAH7i3Lp79s5Kpe+kg6thQtqpaVai19HMoDW1SXNF9Ae71p7HGQ@mail.gmail.com> <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 <CAH7i3Lp79s5Kpe+kg6thQtqpaVai19HMoDW1SXNF9Ae71p7HGQ@mail.gmail.com>
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 <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://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>
X-Mailman-Original-Message-ID <20191030172400.pom6dbi7afqpzxtu@chaz.gmail.com>
X-Mailman-Original-References <CAH7i3Lp79s5Kpe+kg6thQtqpaVai19HMoDW1SXNF9Ae71p7HGQ@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15540

Show key headers only | View raw


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

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


Thread

Re: Parameter expansion resulting empty treated as if it's not empty Stephane Chazelas <stephane.chazelas@gmail.com> - 2019-10-30 17:24 +0000

csiph-web