bug-coreutils
[Top][All Lists]
Advanced

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

Re: cp command potental problem


From: Eric Blake
Subject: Re: cp command potental problem
Date: Wed, 17 Jun 2009 12:43:44 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.21) Gecko/20090302 Thunderbird/2.0.0.21 Mnenhy/0.7.6.666

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

According to Bob Proulx on 6/17/2009 11:12 AM:
> If there are three program arguments then the last one must be a
> directory or it is an error.  But with only two it isn't possible to
> determine the caller's intention.

It is also possible to write shell functions or aliases so that you can
avoid some of these mistakes.  For example:

$ alias safe_copy='cp -n'
$ safe_copy file*.txt

when given only two file names from the glob will be a silent no-op rather
than overwriting the second file with contents from the first, but can
still be overridden when you mean for the overwrite to happen:

$ safe_copy -i file*.txt
cp: overwrite `file1.txt'? y

On the other hand, I just noticed that with -v, there is nothing output to
make it obvious when a copy was omitted because -n took effect; maybe it
would make sense for 'cp -vn' to be verbose about files that it refused to
copy because it would have clobbered a destination?

- --
Don't work too hard, make some time for fun as well!

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

iEYEARECAAYFAko5OWAACgkQ84KuGfSFAYAWVwCfWwz1qyfnaEjDdlGpN/aYslrD
B7IAoL2kTuWazBVaaG8gRoDKF5m1gvx7
=3Vzm
-----END PGP SIGNATURE-----




reply via email to

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