Comparison problem with case modification expansion in bash-4.3
From:
Corentin Peuvrel
Subject:
Comparison problem with case modification expansion in bash-4.3
Date:
Tue, 3 Nov 2015 15:03:56 +0100
User-agent:
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0
Hi,
I think I found a bug in bash-4.3 (4.3.42 in fedora 21), that seems to exists
for a long time (at least from 4.1.2 in Centos 6).
I found a fairly simple way to reproduce it : you have to initialize a variable
to an empty string, and do a comparaison to it while doing the case
modification expansion ${var,,}
This doesn't work :
# foo="" ; [[ bar == *"${foo,,}"* ]] && echo ok
While this works fine :
# foo="" ; [[ bar == *"${foo}"* ]] && echo ok
ok
If you unset the variable, it works as we want :
# unset foo ; [[ bar == *"${foo,,}"* ]] && echo ok
ok
If the variable is not empty, it also works normally :
# foo="A" ; [[ bar == *"${foo,,}"* ]] && echo ok
ok
I hope it's not already known, but I couldn't find anything on the net.
Thank you,
Corentin Peuvrel