bug-bash
[Top][All Lists]
Advanced

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

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


From: Eric Pruitt
Subject: Behavior of ${var/*/text} has changed
Date: Fri, 16 Sep 2016 12:06:53 -0700
User-agent: Mutt/1.5.23 (2014-03-12)

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-unknown-linux-gnu' 
-DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -g -O2 
-Wno-parentheses -Wno-format-security
uname output: Linux sinister 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 
(2016-09-03) x86_64 GNU/Linux
Machine Type: x86_64-unknown-linux-gnu

Bash Version: 4.4
Patch Level: 0
Release Status: release

Description:
        In Bash 4.3, "${var/*/text}" would generate "" if var was a zero-length
        string and "text" if it contained at least one character. In Bash 4.4, 
this
        is no longer the case. I'm not sure if this is necessarily a bug, but I 
was
        unable to find this change in behavior in the change log or man page.

Repeat-By:
        Bash 4.3:
        address@hidden:~$ echo ${VAR/*/VAR was not empty}
        VAR was not empty
        address@hidden:~$ VAR=
        address@hidden:~$ echo ${VAR/*/VAR was not empty}
        
        address@hidden:~$

        Bash 4.4:
        address@hidden:~$ VAR=NotEmpty
        address@hidden:~$ echo ${VAR/*/VAR was not empty}
        VAR was not empty
        address@hidden:~$ VAR=
        address@hidden:~$ echo ${VAR/*/VAR was not empty}
        VAR was not empty
        address@hidden:~$

Fix:
        As a work-around, I have changed the expressions I'm using from
        ${VAR/*/...} to ${VAR/?*/...}. Since it is not clear to me if this is
        actually a bug, I'm not sure what that fix should be. Maybe there
        should be a new "compat..." option.



reply via email to

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