bugGNU Core Utilities - Bugs: bug #25946, mv/cp/ls/cd cannot cope with...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #25946: mv/cp/ls/cd cannot cope with leading dash (-) in directory names without path

Submitted by:  Hendrick Musche <hmu>
Submitted on:  Fri 20 Mar 2009 10:43:15 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: Closed

Fri 20 Mar 2009 10:58:00 PM UTC, 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

Eric Blake <ericb>
Project Administrator
Fri 20 Mar 2009 10:48:52 PM UTC, comment #1:

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.

Micah Cowan <micahcowan>
Fri 20 Mar 2009 10:43:15 PM UTC, original submission:

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

Hendrick Musche <hmu>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ericb (Posted a comment)
  • -unavailable- added by micahcowan (Posted a comment)
  • -unavailable- added by hmu (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 20 Mar 2009 10:58:00 PM UTCericbStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1