bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Behavior of ${var/*/text} has changed


From: Greg Wooledge
Subject: Re: Behavior of ${var/*/text} has changed
Date: Fri, 16 Sep 2016 15:22:29 -0400
User-agent: Mutt/1.4.2.3i

On Fri, Sep 16, 2016 at 12:06:53PM -0700, Eric Pruitt wrote:
>       Bash 4.3:
>       address@hidden:~$ VAR=
>       address@hidden:~$ echo ${VAR/*/VAR was not empty}
>       

>       Bash 4.4:
>       address@hidden:~$ VAR=
>       address@hidden:~$ 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]