Cp can't hardlink unqualified wildcard

Eric Blake eblake@redhat.com
Sat Oct 20 19:35:00 GMT 2012


On 10/20/2012 12:50 PM, Lawrence Mayer wrote:
> Cp can't hardlink unqualified wildcard
> 
> cp -l * DIRECTORY
> 
> fails with error 'cp: target `file' is not a directory'

Most likely, this is not an error in cp, but a misunderstanding on your
part about how globbing operates.  I bet you have a file in your current
directory whose name starts with '-', and is thus being treated as an
option by cp.

> 
> But the equivalent
> 
> cp -l ./* DIRECTORY

No, that's not quite equivalent - it guarantees that the glob won't be
mis-handled as an option.  Likewise,

cp -l -- * DIRECTORY

will avoid treating the glob as an option.  Not only that, but this is a
FAQ:
https://www.gnu.org/software/coreutils/faq/#I-have-a-file-_0027_002df_0027-and-it-affects-rm_002e

> 
> AND
> 
> cp -l PATH OF WORKING DIRECTORY/* DIRECTORY

Sorry, but that's not what you typed.  It helps to show actual examples
when claiming you have a bug.


-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20121020/4361b368/attachment.sig>


More information about the Cygwin mailing list