Op 02-07-16 om 11:30 schreef Andreas Schwab: > "Ibrahim M. Ghazal" <img...@gmail.com> 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 broken: $ 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). Thanks, - Martijn