tilde expansion with a variable

Inizio della pagina
Allegati:
Messaggio come e-mail
+ (text/plain)
Delete this message
Reply to this message
Autore: Lynn David Newton
Data:  
Oggetto: tilde expansion with a variable
ldn> I've known for years that one can't do tilde
ldn> expansion with a variable name, e.g.,


ldn> WHO=joeuser
ldn> cd ~$WHO


ldn> doesn't work, but I have never quite grokked
ldn> exactly why, or whether there is a workaround.


As usual, I found the answer moments after sending off
my question.

The solution is this:

eval cd \~$WHO

This in both bash and ksh.

The problem is because of the order of evaluation of
operators. ~ has higher precidence than $.

That little tidbit of knowledge is going into my facts
file.

--
Lynn David Newton
Phoenix, AZ