5 ms·
> The point I'm making here is that it's actually quite difficult to get a string that literally has the contents you want. It's not difficult, it's just tedio
by dozzie 8y ago
> The point I'm making here is that it's actually quite difficult to get a string that literally has the contents you want.
It's not difficult, it's just tedious.
foo=$(whatever).
foo=${foo%.}
- mehrdadn 8y agoThat's not general POSIX, right? I seem to recall it's Bash-specific? (P.S. I think you forgot quotes?) The other problem (which I guess I accidentally brushed under the rug when I singled out "variables") is that having to do this actually means you need to put it in a variable. If you're nesting subshells, this gets pretty darn tedious, easy to forget about, and difficult to read pretty quickly... it seems you wouldn't consider that "difficulty" and think of it as "just tediousness", but I think if something is too easy to do incorrectly and too tedious to get right, that's also a kind of added difficulty.
- dozzie 8y ago> That's not general POSIX, right? I seem to recall it's Bash-specific? (P.S. I think you forgot quotes?) Wrong. (And no, I did not.) POSIX, or rather SUS (I've never had an access to POSIX), mandates ${foo%...} syntax and its three cousins. And assignment is not subject to word splitting for variable expansion.