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


Groups > gnu.bash.bug > #15538

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

From Oğuz <oguzismailuysal@gmail.com>
Newsgroups gnu.bash.bug
Subject Parameter expansion resulting empty treated as if it's not empty
Date 2019-10-30 14:12 +0300
Message-ID <mailman.43.1572433984.22196.bug-bash@gnu.org> (permalink)
References <CAH7i3Lp79s5Kpe+kg6thQtqpaVai19HMoDW1SXNF9Ae71p7HGQ@mail.gmail.com>

Show all headers | View raw


Since

bash -c '${1##*""}' _ foo

prints an empty line, I was expecting

bash -c '${1##*"${1##*}"}' _ foo

to print an empty line too, but instead it prints foo.

Other shells I could find don't have this problem

$ sh -c 'echo "${1##*"${1##*}"}"' _ bar

$ ash -c 'echo "${1##*"${1##*}"}"' _ bar

$ dash -c 'echo "${1##*"${1##*}"}"' _ bar

$ ksh -c 'echo "${1##*"${1##*}"}"' _ bar

$ yash -c 'echo "${1##*"${1##*}"}"' _ bar

$ zsh -c 'echo "${1##*"${1##*}"}"' _ bar

$ bash -c 'echo "${1##*"${1##*}"}"' _ bar
bar
$ bash --posix -c 'echo "${1##*"${1##*}"}"' _ bar
bar

Is this a bug?

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


Thread

Parameter expansion resulting empty treated as if it's not empty Oğuz <oguzismailuysal@gmail.com> - 2019-10-30 14:12 +0300

csiph-web