13

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?

Johannes Kuhn
  • 12,878
  • 3
  • 41
  • 66
Yoo
  • 15,338
  • 6
  • 37
  • 46

2 Answers2

16

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!

P Shved
  • 87,005
  • 15
  • 114
  • 161
6

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

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

pilcrow
  • 51,771
  • 11
  • 83
  • 128
  • 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 Nov 06 '09 at 07:12
  • bash looks for tildes after ':' in the replacement string. 'disk:bacon=...' is not a valid variable assignment. – outis Nov 06 '09 at 07:18
  • 1
    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 Nov 06 '09 at 07:32