it going to fail if the variable has any spaces
Quoting and escaping. I mentioned that already, it's a basic part of the understanding and is not surprising at all.
Again something most people arent going to want.
You're assuming a lot. The fact that the variable substitution could expand to multiple arguments (because it's really just simple textual substitution) is in fact very powerful and useful (you can pass multiple arguments in one variable, for example), and you can always quote if you really want it to expand to one argument, the same way you would quote strings containing spaces to make them one argument. This is very consistent; observe that if $SOMETHING contains "foo bar" (without the quotes), then
grep $SOMETHING
is exactly the same as grep foo bar
but what you seem to be suggesting is that it becone grep "foo bar"
...what? Where did those quotes come from? More importantly, how do you propose to remove them? My point is, the current behaviour is simple and consistent as well as powerful and flexible, and I suspect people are just going "it doesn't work the way I thought it would" and downvoting my comment when they really haven't thought about the perfectly logical explanation for why things are the way they are. The original developers of the shell language were most certainly not stupid.The default split behavior basically forces you to always quote expansions which is tiresome. It also is confusing because almost no other programming language works like that.
And when you assigned SOMETHING you did wrote SOMETHING="foo bar" (with quotes) so it sorta makes sense visually also.
Also, for the case of passing multiple arguments to a command, just use an array:
SOMETHING=(foo bar)
grep "${SOMETHING[@]}"
It will handle arguments with spaces correctly, unlike using a string variable and splitting it on spaces. There is no reason to ever use space splitting, unless you're maintaining some legacy interface where you can only pass a string instead of an array.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/f...