Adam Nielsen <[EMAIL PROTECTED]> [2002-08-28 18:55:39 +1000]:
> When I type a command such as this:
> 
> $ cp * /some/folder
> 
> And there is a file called "-CAT_NO3.022" in the current directory, I get 
> this response:
> 
> cp: invalid option -- C
> Try `cp --help' for more information.
> 
> It looks as if the "-C" at the start of the filename is being treated as a 
> parameter to cp.  I'm using fileutils 4.1 (Linux x86 2.4.18, ext3.)  Please 
> let me know if I've found a real live bug!

Sorry, no bug here.  The shell expands '*' glob characters and invokes
the command.  The command does not see the '*' but only sees
characters on the command line.  In the strictest sense your command
'cp * /some/folder' is unreliable because it depends upon the contents
of the directory.

Since the file name begins with a '-' it looks like an option to the
command.  You need to force it to not look like an option.  Put a ./
in the front of it.  Or give it the full file name path.  Or tell the
command you are through with options by using the double dash to end
all option processing.  This is common to most traditional UNIX
commands.

  cp ./* /some/folder
  cp -- * /some/folder

And the same for other utilities too.

  mv ./-stuff differentstuff
  mv -- -stuff differentstuff

The FAQ contains more information.

  http://www.gnu.org/software/fileutils/doc/faq/

Bob


_______________________________________________
Bug-fileutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-fileutils

Reply via email to