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?

Reply via email to