home directory expansion (~) within an argument

Yoo picture Yoo · Nov 6, 2009 · Viewed 10.6k times · Source

When I enter the following (BASH):

rdesktop -r disk:bacon=~/bacon host

It does not expand to

rdesktop -r disk:bacon=/home/me/bacon host

It seems the "disk:" part is the problem as can be seen in:

$ echo bacon=~/bacon disk:bacon=~/bacon

bacon=/home/me/bacon disk:bacon=~/bacon

How can I make tilde expand?

Answer

P Shved picture P Shved · Nov 6, 2009

While ~ does not expand (it's used as specially routed of the path), $HOME does.

rdesktop -r disk:bacon=$HOME/bacon host

But be careful with environment-changing su!