[bug #25946] mv/cp/ls/cd cannot cope with leading dash (-) in directory names without path
URL: http://savannah.gnu.org/bugs/?25946 Summary: mv/cp/ls/cd cannot cope with leading dash (-) in directory names without path Project: GNU Core Utilities Submitted by: hmu Submitted on: Fr 20 Mär 2009 22:43:15 GMT Category: None Severity: 3 - Normal Item Group: None Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any ___ Details: Probably just a minor bug, thought I'd file it anyway. I just stumbled upon the error that I couldn't cd oder ls in a directory named - test -. Any attempt with quotation marks or escaping the dash fails with: ~$ cd - test - bash: cd: - : invalid option cd: usage: cd [-L|-P] [dir] However, if used with a path, it works ok: ~$ cd ./- test - ~/- test -$ Is this intended? I know its a bit lazy leaving the path away, but it did took me quite a while to figure it out. btw, this is with coreutils 6.10 on ubuntu jaunty. Sincerely, Hendrick ___ Reply to this item at: http://savannah.gnu.org/bugs/?25946 ___ Nachricht geschickt von/durch Savannah http://savannah.gnu.org/ ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
[bug #25946] mv/cp/ls/cd cannot cope with leading dash (-) in directory names without path
Follow-up Comment #1, bug #25946 (project coreutils): cd -- - test - should also work fine. This is not only expected behavior for cd and ls, but for virtually any command on a Unix-style system. Arguments that begin with a - are interpreted as strings of options (think of ls -ltc), so cd (via the getopt library function) believes you are trying to pass it a string of options that includes (among other things) the space character. That's why the special -- argument exists: it tells getopt to treat any following arguments as true program arguments, and not as options. ___ Reply to this item at: http://savannah.gnu.org/bugs/?25946 ___ Message sent via/by Savannah http://savannah.gnu.org/ ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils
[bug #25946] mv/cp/ls/cd cannot cope with leading dash (-) in directory names without path
Update of bug #25946 (project coreutils): Status:None = Invalid Open/Closed:Open = Closed ___ Follow-up Comment #2: And if you happen to encounter an older program that doesn't accept the magic -- argument, you can always fall back to './-file' instead of '-file'. By the way, this is a FAQ: http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#I-have-a-file-called-_003csamp_003e_003cspan-class_003d_0022option_0022_003e_002d_002dhelp_003c_002fspan_003e_003c_002fsamp_003e_002e-How-do-I-remove-it_003f ___ Reply to this item at: http://savannah.gnu.org/bugs/?25946 ___ Message sent via/by Savannah http://savannah.gnu.org/ ___ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils