I'm attempting to get into the directory /cygdrive/c/Users/my dir/Documents
:
$ DOCS="/cygdrive/c/Users/my\ dir/Documents"
$ echo $DOCS
/cygdrive/c/Users/my\ dir/Documents
$ cd $DOCS
-bash: cd: /cygdrive/c/Users/my\: No such file or directory
$ cd /cygdrive/c/Users/my\ dir/Documents
(success)
When I manually type it in, the backspace does its escape character thing, but not when I use parameter expansion with the variable DOCS
.
I tried other variations such as no backslash.
$ DOCS=/cygdrive/c/Users\ dir/Documents
$ echo $DOCS
/cygdrive/c/Users/my dir/Documents
$ cd $DOCS
-bash: cd: /cygdrive/c/Users/my: No such file or directory
or
$ DOCS="/cygdrive/c/Users/my dir/Documents"
$ echo $DOCS
/cygdrive/c/Users/my dir/Documents
$ cd $DOCS
-bash: cd: /cygdrive/c/Users/my: No such file or directory
The same happens for $HOME
:
$ echo $HOME
/home/my dir
cd $HOME
doesn't work either. Quotes must be put around it.
What the heck:
$ DOCS="\"/cygdrive/c/Users/my dir/Documents\""
$ echo $DOCS
"/cygdrive/c/Users/my dir/Documents"
$ cd $DOCS
-bash: cd: "/cygdrive/c/Users/my: No such file or directory
DOCS="/cygdrive/c/Users/my dir/Documents"
cd
, usecd "$DOCS"