[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cp command will copy to subdirectory without appending /

From: Bob Proulx
Subject: Re: cp command will copy to subdirectory without appending /
Date: Mon, 19 Oct 2009 23:59:25 -0600
User-agent: Mutt/1.5.18 (2008-05-17)

Todd Partridge wrote:
> The cp command will copy to a subdirectory without an appending /

You have reached bug-bash, not bug-coreutils.  The 'cp' program is in
the GNU Coreutils project and so bug reports for 'cp' should go to
address@hidden and not to bug-bash.  The bug-bash list is for
bugs and discussion about bash.

> mkdir test test2
> touch abc test
> touch bcd test2

I think you have typed this in incorrectly.  That produces:


> cp -R test2 test

Because test is a directory test2 will be copied into that directory.
With the above that produces:


> ls test
> test2 abc

That result cannot be produced from the given commands.  Please
rephrase the question.

> Since the cp command can also rename

I think you misunderstand how cp works.  A quick and casual summary
here.  If the target is not a directory then the source file
(singular) is copied to the destination.  If the target is a directory
then cp copies the source files (one or more) into the destination
directory.  If the target has an appended '/' then the destination
must be a directory.

Here is the full standards document:


> I think the proper behavior here for 'cp -R test2 test' would be to
> error and print that 'Folder already exists'.

Of course that would break decades of scripts which expect the
standard behavior.  I don't understand why would you change this long
standing useful behavior.  Could you say a few words more about what
your problem is with the current behavior?

> Appending a / would imply the directory:
> cp -R test2 test/
> This usage will remove the ambiguity of the command between the copy
> function and the rename function.

Please rephrase your question and send it to address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]