On 5/22/19 5:43 AM, Greg Wooledge wrote: > On Wed, May 22, 2019 at 05:25:43PM +0700, Robert Elz wrote: >> Date: Tue, 21 May 2019 22:11:20 +0000 >> From: Charles-Henri Gros <charles-henri.g...@synopsys.com> >> Message-ID: >> <b51a83f93b459b479b6c4c3fbfe3f9310156f52...@us01wembx1.internal.synopsys.com> >> >> | The existence or not of the file should not have any effect. >> >> But it does, and is intended to. If the mattern matches a file >> (when patyhname expanded as a result of the unquoted command substitution) >> you get the file name produced. If it does not match a file, >> the pattern is left untouched. That is the way that things are >> supposed to work. > With glob metacharacters, sure. But none of the characters in his > variable are glob metacharacters. > > There is definitely something weird happening here. > > wooledg:/tmp/x$ echo "$BASH_VERSION" > 5.0.3(1)-release > wooledg:/tmp/x$ touch 'a$.class' > wooledg:/tmp/x$ i='a\$.class'; echo {$i} "{$i}" > {a\$.class} {a\$.class} > wooledg:/tmp/x$ i='a\$.class'; echo $i "{$i}" > a$.class {a\$.class} > > Other versions of bash, plus ksh and dash, don't behave this way. > > wooledg:/tmp/x$ bash-2.05b > wooledg:/tmp/x$ i='a\$.class'; echo $i "{$i}" > a\$.class {a\$.class} > > wooledg:/tmp/x$ bash-4.4 > wooledg:/tmp/x$ i='a\$.class'; echo $i "{$i}" > a\$.class {a\$.class} > > wooledg:/tmp/x$ ksh > $ i='a\$.class'; echo $i "{$i}" > a\$.class {a\$.class} > > wooledg:/tmp/x$ dash > $ i='a\$.class'; echo $i "{$i}" > a\$.class {a\$.class} > > It seems to be unique to bash 5. If it's a bug fix, then I'm not > understanding the rationale. Backslashes shouldn't be consumed during > glob expansion. > > This is also not limited to $ alone. It happens with letters too. > > wooledg:/tmp/x$ touch i > wooledg:/tmp/x$ i='\i' j='\j' > wooledg:/tmp/x$ echo $i $j > i \j > > Standard disclaimers apply. Stop using unquoted variables and these > bugs will stop affecting you. Nevertheless, Chet may want to take a > peek.
What unquoted variables? Are you talking about the "$()" expansion? The problem I'm trying to solve is to iterate over regex-escaped file names obtained from a "find" command. I don't know how to make this work. It works with other versions of bash and with other shells. The original is closer to something like this: for file in $(find ... | sed 's/\$/\\$/g'); do grep -e "$file" someinput; done It used to work. Now it doesn't. I do not know how to make it work again. -- Charles-Henri Gros