[Top][All Lists]

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

Severe IFS glob bug needs patch [was: Setting IFS='*' causes bash to fre

From: Martijn Dekker
Subject: Severe IFS glob bug needs patch [was: Setting IFS='*' causes bash to freeze on tab completion]
Date: Thu, 3 Nov 2016 22:58:34 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

Op 02-07-16 om 11:30 schreef Andreas Schwab:
> "Ibrahim M. Ghazal" <address@hidden> writes:
>> After further investigation, the problem seems to be that when IFS is
>> set to '*', case *) doesn't get executed. Is this the intended
>> behavior?
>> For example:
>> IFS='*'; case "foo" in *) echo "got here";; esac
>> doesn't print "got here".
> The same issue exists for the other glob special characters ? [ ] .

Op 02-07-16 om 15:37 schreef Chet Ramey:
> Yep, that's a bug.  Thanks for the report and reproducer.  The problem is
> that the `*' ends up being matched literally instead of as a matching
> character.  This will be fixed in the next release of bash.

Unfortunately, this was only partially fixed in 4.4. The glob pattern
matching in 'case' and '[[' was fixed, but pathname expansion is still

$ IFS='?*[]'
$ ls *
ls: *: No such file or directory
$ touch a && ls ? [a]
ls: ?: No such file or directory
ls: [a]: No such file or directory

(Needless to say, this works fine on every non-bash shell.)

While this bug is relatively rarely triggered (since glob characters are
rarely put in IFS), it's actually REALLY SEVERE in its effects. Many if
not most scripts use 'case'/'[[' glob pattern matching or pathname
expansion at some point, so breaking either of these under any
circumstances is a big deal.

And when things do break, they break catastrophically. Not just your own
program breaks, but any third-party add-ons or libraries you're using
break as well.

While including any of the characters *, ?, [, ] in IFS might be rare,
strings do sometimes have values separated by one of these, so it's a
perfectly legitimate use case to split something on these characters.

So, in addition to fixing pathname expansion for 4.4, I hope you would
consider releasing a patch fixing both aspects of this bug for earlier
versions, at least down to 3.2 (which will forever be the default
version on Mac OS X, since Apple won't touch the GPL3).


- Martijn

reply via email to

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