[Top][All Lists]

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

bug#6353: cp and mv with single wild card argument acts as if multiple a

From: Davide Brini
Subject: bug#6353: cp and mv with single wild card argument acts as if multiple arguments were entered.
Date: Fri, 4 Jun 2010 21:49:08 +0100
User-agent: KMail/1.12.4 (Linux/2.6.32-gentoo-r10; KDE/4.3.5; x86_64; ; )

On Friday 04 June 2010, Darwin Gregory wrote:

> If you execute "cp /path/*" the command expands the wildcard, and treats
>  the last file as the destination directory.  If the last file in /path/ is
>  not a directory the command fails, but not with the appropriate error. 
>  However, if the last file in the directory (or other wildcard expansion)
>  is a directory, it will copy all earlier files in the expansion to that
>  directory.
> The same happens for mv.  I did mv * in my home directory where the last
> entry was a workspace subdirectory.  It moved all of my files and
> directories to my workspace subdirectory.
> I feel this is an unacceptable outcome for a single argument that is a
> wildcard, since whether it works or not is based on the arbitrary presence
> or absence of a directory as the final element in the wildcard expansion.
> It would be much better to fail with an error indicating  "missing
> destination file operand" as it does if the first argument does not
> contain a wildcard.
> Also, if a wildcard expansion contains exactly 2 elements, the second is
> treated as a target whether or not it is a directory, causing a potential
> overlay of data.

cp and mv have no fault. It's the shell that expends the wildcard, so cp and 
mv do not even see it; they just think they've been invoked with multiple 
arguments, and behave as expected.


reply via email to

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