On Fri, Sep 16, 2016 at 12:06:53PM -0700, Eric Pruitt wrote:
> Bash 4.3:
> ericpruitt@sinister:~$ VAR=
> ericpruitt@sinister:~$ echo ${VAR/*/VAR was not empty}
>
> Bash 4.4:
> ericpruitt@sinister:~$ VAR=
> ericpruitt@sinister:~$ echo ${VAR/*/VAR was not empty}
> VAR was not empty
Off hand I'd say the bash 4.4 behavior is correct. * matches 0 or
more characters, so it should match an empty or undefined variable.
> Fix:
> As a work-around, I have changed the expressions I'm using from
> ${VAR/*/...} to ${VAR/?*/...}.
That, or ${VAR:+not empty} which is how I suggest testing for variable
set-and-not-empty-ness.
http://mywiki.wooledge.org/BashFAQ/083