views:

174

answers:

2

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?

+4  A: 

rdesktop -r disk:bacon=$(echo ~/bacon) host

will do it. It won't please the eye, but it will work.

pilcrow
Do you know why it doesn't work? I've been reading the manual and have found only this *"Each variable assignment is checked for unquoted tilde-prefixes immediately following a : or the first =. In these cases, tilde expansion is also performed. Consequently, one may use file names with tildes in assignments to PATH, MAILPATH, and CDPATH, and the shell assigns the expanded value."*
Vinko Vrsalovic
But from that, it looks like as if the disk:bacon=~/bacon should work...
Vinko Vrsalovic
bash looks for tildes after ':' in the replacement string. 'disk:bacon=...' is not a valid variable assignment.
outis
In particular, 'disk:bacon=...' isn't a variable assignment both because it isn't in a valid part of the command (variable assignments must come before the command name) and ':' isn't a valid character for a variable name.
outis
+4  A: 

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!

Pavel Shved