geek

BASH puzzle

Although only 1½ people read this blog, I’m hoping I’ll get some responses to this puzzle. I figured out a solution, but I’m worried i was being too clever and that there’s an even simpler BASH way of handling this.

Shell variable interpolation

Alright, this is fairly geeky, but I’d like to know if there is a better way of doing this.

Something I love about perl is how many places it lets you interpolate. Being used to this flexibility, I wanted to do something similar in a shell script (in particular, my .bash_profile). This is my first stab at it: