3 ms·
Indeed. Which is why you should use the built-in parameter expansion provided by bash for easily removing a suffix, instead of an external program. The thing a
by tpoacher 3y ago
Indeed. Which is why you should use the built-in parameter expansion provided by bash for easily removing a suffix, instead of an external program.
The thing about spaces (and expansion more generally) as I understand it is this. At some point the bash designers had a choice how to represent expanded, unexpanded, and verbatim strings. One could argue that verbatim should have been the default, with expanded using single quotes, and unexpanded using double quotes, such that you would only get expansion if you really wanted it. This might have been my choice if I had designed it.
I'm guessing, however, that the designers quite reasonable went for the opposite logic, which was, if you use a $ in your string, you're probably after expansion, rather than a verbatim $ symbol (and you can always escape it in the unlikely scenario that you did want a verbatim one). So presumably they chose expanded as the default because it would be the most common, leaving single quotes for verbatim instead.