3 ms·
grep -w is pretty useless either way. Ok I might sound like I just try to brush off the issue here but it's not intuitive anyways that it needs to know the loca
by iforgotpassword 6y ago
grep -w is pretty useless either way. Ok I might sound like I just try to brush off the issue here but it's not intuitive anyways that it needs to know the locale to properly match in the first place. The Italian person might be caught off guard when trying to find a Swedish word in a file, because you need to remember to switch the locale first. And if grep actually uses isalnum for -w then the Italian and Greek and Thai people will be out of luck either way since they all use utf8 today and ò is two bytes. Good look if you work with a multi-language file and have to constantly switch. But that's not even a problem specifically with POSIX or glibc but language in general; there are languages that don't have any separators between words so you already lost.
The crash is a problem with the function, specifically with glibc. You might even put into question why POSIX defines out of range values as UB instead of requiring it to return false but that's yet another can of worms we better not open here. I fully blame not doing any range checks and doing an oob array access on glibc. UB doesn't force you to create an implementation that crash and burns... Returning false would be great. Maybe abort if you're anal. Have it return something random if you're concerned about speed. But don't freaking crash! The libc should work with the dev, not against them.