15

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?

2 Answers 2

17

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!

Sign up to request clarification or add additional context in comments.

Comments

6

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

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

3 Comments

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."
bash looks for tildes after ':' in the replacement string. 'disk:bacon=...' is not a valid variable assignment.
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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.