Changing to a directory named -
I have a script that traverses the directory tree using pushd
and popd
. It 开发者_高级运维is choking on a directory named -
. I have tried:
pushd -- -
But the dash is still interpreted as an option (and the previous directory is pushed on the stack). I have the same problem with cd
.
In different flavors, this is an interview question. (How would I remove a file named "-"?)
$ cd ./-
$ pushd ./-
$ pushd ./$next
$ pushd $PWD/- # Yay JL
$ pushd /what/ever/-
精彩评论