bug-coreutils
[Top][All Lists]
Advanced

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

Re: wildcard feature?


From: Eric Blake
Subject: Re: wildcard feature?
Date: Mon, 11 Sep 2006 06:22:14 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.5) Gecko/20060719 Thunderbird/1.5.0.5 Mnenhy/0.7.4.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Werner Adler on 9/11/2006 5:14 AM:
> Hello,
> 
> I don't know, if this is a bug or just the misuse of a feature:
> 
> if I have two files with the same ending (could be any part of the
> name), say 1.test and 2.test, and I want to copy both files to a
> directory, but accidently type "return" before entering the directory name:
> 
> cp *.test
> 
> the second file is overwritten by the first file (I expected to get an
> error message and was pretty surprised about that behaviour). (Funny)
> Feature or bug?

Feature required by POSIX.  The shell expands wildcards before passing
arguments to cp, so all cp sees is "cp 1.test 2.test", and it has no way
of knowing whether you meant to overwrite 2.test or had a wildcard typo.
Aliasing cp to 'cp -i' can catch this, but may prove annoying for other
situations.  Another idea, relying on GNU features, would be getting in
the habit of 'cp --target-directory=. *.test"; by explicitly specifying
the target directory with an option, you no longer have to worry about
whether the wildcard expanded to exactly two filenames, or expanded to
multiple filenames the last of which was a directory.  Or you can also
experiment with the backup features, so that if this does happen to you,
you would at least still be able to retrieve 2.test from its backup name.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFBVT184KuGfSFAYARAhS2AKCgDjInwfnUWHkj6L+fiimucZWtbACgsJq5
CB0qQmFlqKnb8Z0+oyb9T8A=
=92N6
-----END PGP SIGNATURE-----




reply via email to

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