tilde expansion with a variable
G.D.Thurman
plug-discuss@lists.plug.phoenix.az.us
Wed, 5 Feb 2003 09:08:20 -0700 (MST)
On Wed, 5 Feb 2003, Lynn David Newton wrote:
> I've known for years that one can't do tilde expansion
> with a variable name, e.g.,
>
> WHO=joeuser
> cd ~$WHO
>
> doesn't work, but I have never quite grokked exactly
> why, or whether there is a workaround.
>
$ is my prompt. Only executed with bash.
The following command-lines were tried.
$ echo $SHELL
/bin/bash
$ WHO=root
$ eval cd ~$WHO
bash: cd: /root: Permission denied
Potential solution?
>From your code...
cp $files ~$u
switch to
eval cp $files ~$u
Thurman