3 ms·
> Even to this day, years later, I have to look up bits and pieces here and again if I don't use some of the ${}-type substitutions frequently. In that case I
by xiaq 2y ago
> Even to this day, years later, I have to look up bits and pieces here and again if I don't use some of the ${}-type substitutions frequently.
In that case I think you should give Elvish a chance then :)
Honestly one of the motivations for writing a shell language was that I could never remember which of ${x%y} and ${x#y} is for trimming the suffix vs prefix. So Elvish just use function syntax - "str:trim-suffix $x y" and "str:trim-prefix $x y" - which I highlighted in the explainer of the first snippet (https://elv.sh/learn/scripting-case-studies.html#jpg-to-png.elv https://elv.sh/learn/scripting-case-studies.html#jpg-to-png....).
- saurik 2y ago# is to the left of $ and removes the prefix. % is to the right of $ and removes the suffix.
- SpaghettiCthulu 2y agoI, like the person you replied to, will surely remember it for good thanks to your reminder.
- saurik 2y agoI mean, people learn silly things all the time; I think, often, learning the pattern behind something can make a thing much more transparent... I, too, struggled with this particular distinction until I realized that the choice of characters wasn't, in fact, arbitrary.