Created
June 28, 2011 06:13
-
-
Save matthewrudy/1050592 to your computer and use it in GitHub Desktop.
Trying to cd to a directory with a hypen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /var/folders/*whatever*/ has a folder named '-Tmp-' | |
$ ls | |
-Caches-/ -Tmp-/ | |
# lets try and CD there | |
$ cd -Tmp- | |
-bash: cd: -T: invalid option | |
cd: usage: cd [-L|-P] [dir] | |
# or maybe make sure its a directory | |
$ cd -Tmp-/ | |
-bash: cd: -T: invalid option | |
cd: usage: cd [-L|-P] [dir] | |
# try and escape the first - | |
$ cd \-Tmp- | |
-bash: cd: -T: invalid option | |
cd: usage: cd [-L|-P] [dir] | |
# quote it | |
$ cd '-Tmp-' | |
-bash: cd: -T: invalid option | |
cd: usage: cd [-L|-P] [dir] | |
# double quote it | |
$ cd "-Tmp-" | |
-bash: cd: -T: invalid option | |
cd: usage: cd [-L|-P] [dir] | |
# escape it in the quotes | |
$ cd '\-Tmp-' | |
-bash: cd: \-Tmp-: No such file or directory | |
# escape it in the double quotes | |
$ cd "\-Tmp-" | |
-bash: cd: \-Tmp-: No such file or directory | |
# try a "./" hack | |
$ cd ./-Tmp-/ | |
$ echo "WHOOP" | |
WHOOP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
the unix way is to put -- after all your switches to indicate that anything afterwards is not a switch
cd -- -Tmp-