From unknown Mon Jun 23 18:28:43 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#6353 <6353@debbugs.gnu.org> To: bug#6353 <6353@debbugs.gnu.org> Subject: Status: cp and mv with single wild card argument acts as if multiple arguments were entered. Reply-To: bug#6353 <6353@debbugs.gnu.org> Date: Tue, 24 Jun 2025 01:28:43 +0000 retitle 6353 cp and mv with single wild card argument acts as if multiple = arguments were entered. reassign 6353 coreutils submitter 6353 Darwin Gregory severity 6353 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 04 12:16:43 2010 Received: (at submit) by debbugs.gnu.org; 4 Jun 2010 16:16:43 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKZZa-0002QE-Fa for submit@debbugs.gnu.org; Fri, 04 Jun 2010 12:16:42 -0400 Received: from mail.gnu.org ([199.232.76.166] helo=mx10.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKZXz-0002Od-Gj for submit@debbugs.gnu.org; Fri, 04 Jun 2010 12:15:15 -0400 Received: from lists.gnu.org ([199.232.76.165]:35349) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OKZX6-00068g-Ua for submit@debbugs.gnu.org; Fri, 04 Jun 2010 12:14:09 -0400 Received: from [140.186.70.92] (port=46444 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKZX1-0003Is-9s for bug-coreutils@gnu.org; Fri, 04 Jun 2010 12:14:07 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKZWm-0007PY-IV for bug-coreutils@gnu.org; Fri, 04 Jun 2010 12:13:49 -0400 Received: from mail-wy0-f169.google.com ([74.125.82.169]:63329) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKZWm-0007PL-EO for bug-coreutils@gnu.org; Fri, 04 Jun 2010 12:13:48 -0400 Received: by wyb42 with SMTP id 42so46242wyb.0 for ; Fri, 04 Jun 2010 09:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=t57q2QMcWOBAZ5OjhxIARypXPkLZAHvdzUtAaVFIApU=; b=IIwUgtTACwwBodcI/qpgm+7qZ9Xs7Vm5BXK1GXk3OsJLG8fTNLJ2HR3U7VpXVn2w1X hN+RZybeDy5GOWQ6ytr2QpmdIyM6CXq0AEdTJ99rMg83OQjW9dHL+Ac69VyLHSHuBwj5 NTTNNk/mab16a+juu3LgMvbxRXdqiglMKqqjk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=tphJq7f68kOFFeUFcx3mea6pS0b1pDCe0+DyzIkydpJoF4LjAYB7h1D/xyPSRkURPq HYXZftHdeomI4g7TdAycb3xareDrkbgl4MarKcAHQ7Ttg3mojoSAl3pA4GmJZIwflr8K yjaxx9d/runKN820bWgT5BE/RIb98tLwppKIg= MIME-Version: 1.0 Received: by 10.227.141.135 with SMTP id m7mr10869488wbu.205.1275668026405; Fri, 04 Jun 2010 09:13:46 -0700 (PDT) Received: by 10.216.22.146 with HTTP; Fri, 4 Jun 2010 09:13:46 -0700 (PDT) Date: Fri, 4 Jun 2010 12:13:46 -0400 Message-ID: Subject: cp and mv with single wild card argument acts as if multiple arguments were entered. From: Darwin Gregory To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary=0016e659f60e90b5930488369b61 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 04 Jun 2010 12:16:41 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.6 (----) --0016e659f60e90b5930488369b61 Content-Type: text/plain; charset=ISO-8859-1 I did a quick search of the archive, and didn't find this one, but there seems to be a potential logical failure in the cp and mv commands. It may be specific to an implementation, but I feel it is a critical issue. I have tested this on Suse Enterprise 10.x and OpenSuse 11.x (the only implementations I currently have access to). 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. ... Darwin --0016e659f60e90b5930488369b61 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I did a quick search of the archive, and didn't find this one, but= there seems to be a potential logical failure in the cp and mv commands.= =A0 It may be specific to an implementation, but I feel it is a critical is= sue.
=A0
I have tested this on Suse Enterprise 10.x and OpenSuse 11.x (the only= implementations I currently have access to).
=A0
If you execute "cp /path/*" the command expands the wildcard= , and treats the last file as the destination directory.=A0 If the last fil= e in /path/ is not a directory the command fails, but not with the=A0approp= riate error.=A0 However, if the last file in the directory (or other wildca= rd expansion) is a directory, it will copy all earlier files in the expansi= on=A0to that directory.
=A0
The same happens for mv.=A0 I did mv * in=A0my home directory where th= e last entry was a workspace subdirectory.=A0 It moved all of my files and = directories to my workspace subdirectory.
=A0
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=A0of a directory as the final element in the wildcard expansion= .=A0 It would be much better to fail with an error indicating =A0"miss= ing destination file operand" as it does=A0if the first argument=A0doe= s=A0not contain=A0a wildcard.
=A0
Also, if a=A0wildcard expansion contains exactly 2 elements, the secon= d is treated as a target whether or not it is a directory, causing a potent= ial overlay of data.
=A0
... Darwin
=A0
--0016e659f60e90b5930488369b61-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 04 16:44:16 2010 Received: (at 6353) by debbugs.gnu.org; 4 Jun 2010 20:44:16 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKdkW-0004Xp-F5 for submit@debbugs.gnu.org; Fri, 04 Jun 2010 16:44:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKdkT-0004Xk-MM for 6353@debbugs.gnu.org; Fri, 04 Jun 2010 16:44:15 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o54Ki74C006857 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 4 Jun 2010 16:44:08 -0400 Received: from [10.3.242.151] (vpn-242-151.phx2.redhat.com [10.3.242.151]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o54Ki7i2019798; Fri, 4 Jun 2010 16:44:07 -0400 Message-ID: <4C096575.8040305@redhat.com> Date: Fri, 04 Jun 2010 14:43:33 -0600 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-3.fc13 Lightning/1.0b2pre Mnenhy/0.8.2 Thunderbird/3.0.4 MIME-Version: 1.0 To: Darwin Gregory Subject: Re: bug#6353: cp and mv with single wild card argument acts as if multiple arguments were entered. References: In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig4F2E14F77F706C2374F02347" X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-Spam-Score: -8.8 (--------) X-Debbugs-Envelope-To: 6353 Cc: 6353@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.1 (----------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig4F2E14F77F706C2374F02347 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 06/04/2010 10:13 AM, Darwin Gregory wrote: > I did a quick search of the archive, and didn't find this one, but ther= e > seems to be a potential logical failure in the cp and mv commands. It = may > be specific to an implementation, but I feel it is a critical issue. It is generic to how Unix works. Basically, globs are expanded by the shell, prior to the command itself being executed. > If you execute "cp /path/*" the command expands the wildcard, and treat= s the > last file as the destination directory. As it has always done historically, and was standardized by POSIX. > If the last file in /path/ is not a > directory the command fails, but not with the appropriate error. Howev= er, > 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. Yep. > 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 prese= nce > or absence of a directory as the final element in the wildcard expansio= n. But mv has no idea whether you typed a glob or spelled it out on the command line. > 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. How? That information is lost by the shell's glob expansion before ls even starts executing. >=20 > Also, if a wildcard expansion contains exactly 2 elements, the second i= s > treated as a target whether or not it is a directory, causing a potenti= al > overlay of data. This behavior is required by POSIX, but you can use an alias or shell function to instead invoke mv -i or cp -i by default, which will catch common errors like this. For more information on globbing, see this FAQ: http://www.gnu.org/software/coreutils/faq/#expr-2-_002a-3-does-not-work --=20 Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enig4F2E14F77F706C2374F02347 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJMCWV7AAoJEKeha0olJ0NqkSMIAJyK3grCWWmHO/vurrji1dB4 yebovqe8BPVUmWbFm18A0Lki3HFItunxGTIPxYOoQGnZnii4gvsPAfvYo+rpvtqr zDpP2I4/1RolK3uyhmtbSKRZw84qnc8gADAvTXcCihEIn2zXM+i1xC7KXcLvZtv0 PYs/IdDSlh51ibjG9saja1FMLKyxhHnVF5tY9Px9q2GuFqd+d06yJAm9GSvQUCVl KWWlaoT3x17ikPygbI5yShzEEJ5oA2e+R6T59yeLGO/e3Uv5W/ixMox2dNvwJz1q sPTBirOTfOQYkmUtGSRv1UtHg4sjhXL0NrU/C3RjSA6snjCzEVStFzii1GpINOQ= =Y8VW -----END PGP SIGNATURE----- --------------enig4F2E14F77F706C2374F02347-- From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 04 16:45:02 2010 Received: (at 6353) by debbugs.gnu.org; 4 Jun 2010 20:45:02 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKdlF-0004Y5-QA for submit@debbugs.gnu.org; Fri, 04 Jun 2010 16:45:02 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKdlE-0004Xz-05 for 6353@debbugs.gnu.org; Fri, 04 Jun 2010 16:45:00 -0400 Received: from ams by fencepost.gnu.org with local (Exim 4.69) (envelope-from ) id 1OKdl9-000335-V4; Fri, 04 Jun 2010 16:44:55 -0400 From: "Alfred M. Szmidt" To: Darwin Gregory In-reply-to: (message from Darwin Gregory on Fri, 4 Jun 2010 12:13:46 -0400) Subject: Re: bug#6353: cp and mv with single wild card argument acts as if multiple arguments were entered. References: Message-Id: Date: Fri, 04 Jun 2010 16:44:55 -0400 X-Spam-Score: -6.6 (------) X-Debbugs-Envelope-To: 6353 Cc: 6353@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: ams@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.6 (------) If you execute "cp /path/*" the command expands the wildcard, and treats the last file as the destination directory. That is at it should be, * is expanded by the shell, not by the command. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 04 16:52:22 2010 Received: (at 6353) by debbugs.gnu.org; 4 Jun 2010 20:52:22 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKdsM-0004bO-21 for submit@debbugs.gnu.org; Fri, 04 Jun 2010 16:52:22 -0400 Received: from joseki.proulx.com ([216.17.153.58]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKdsK-0004bH-9U for 6353@debbugs.gnu.org; Fri, 04 Jun 2010 16:52:21 -0400 Received: from dementia.proulx.com (dementia.proulx.com [192.168.230.115]) by joseki.proulx.com (Postfix) with ESMTP id 9435221362; Fri, 4 Jun 2010 14:52:15 -0600 (MDT) Received: by dementia.proulx.com (Postfix, from userid 1000) id 85D8C3CC3A1; Fri, 4 Jun 2010 14:52:15 -0600 (MDT) Date: Fri, 4 Jun 2010 14:52:15 -0600 From: Bob Proulx To: Darwin Gregory Subject: Re: bug#6353: cp and mv with single wild card argument acts as if multiple arguments were entered. Message-ID: <20100604205215.GA21747@dementia.proulx.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam-Score: -1.1 (-) X-Debbugs-Envelope-To: 6353 Cc: 6353@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -1.7 (-) Darwin Gregory wrote: > I did a quick search of the archive, and didn't find this one, It gets discussed every so often. Look for file glob or file globbing. > but there seems to be a potential logical failure in the cp and mv > commands. It may be specific to an implementation, but I feel it is > a critical issue. This applies to *all* command line use of shell wildcards. It isn't specific to GNU or GNU coreutils or any other particular command. This is part of the fabric that underlays the entire operating system. > 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 part that you are missing is that the shell expands '*' file glob characters prior to passing the result as arguments to the command. The command invoked does not receive the '*' itself (unless there were no matches at all) and the command cannot tell the difference between the user specifying files explicitly versus having had a file glob expanded. > 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. Yes. That is forty years of expected behavior. Shell wildcards are expanded by the shell before invoking the command. > 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. This is a fundamental behavior of the shell. The Unix philosophy is to separate this behavior out into the shell so that it would be applied uniformly to all commands. Now you may say that this is unacceptable and be shocked by this but if you think about the fact that this has been the standard behavior for four decades then you must realize that there is some value and benefit to this design or it would have been changed and replaced with something different by now. > 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. This is not possible in the Unix command line shell architecture. > 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. That is correct. Don't do that. Note that you are always free to use a different shell that behaves differently. There isn't any requirement that you use bash, or whatever shell you happen to be using at the moment. It just turns out that it is more useful than any of the alternatives. It is so much more useful that you may find it difficult to locate successful alternatives that do not do file glob expansion. And also you would need to use a set of utilities that were designed to match the behavior. Bob From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 04 17:04:42 2010 Received: (at submit) by debbugs.gnu.org; 4 Jun 2010 21:04:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKe4H-0004gU-Ri for submit@debbugs.gnu.org; Fri, 04 Jun 2010 17:04:42 -0400 Received: from mx10.gnu.org ([199.232.76.166]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKe0a-0004ej-Rb for submit@debbugs.gnu.org; Fri, 04 Jun 2010 17:00:54 -0400 Received: from lists.gnu.org ([199.232.76.165]:45444) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1OKe0V-0003zM-VJ for submit@debbugs.gnu.org; Fri, 04 Jun 2010 17:00:48 -0400 Received: from [140.186.70.92] (port=41294 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKe0T-00049d-OW for bug-coreutils@gnu.org; Fri, 04 Jun 2010 17:00:47 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD,T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKe0N-0005V2-Ha for bug-coreutils@gnu.org; Fri, 04 Jun 2010 17:00:44 -0400 Received: from mailout-eu.gmx.com ([213.165.64.42]:42239) by eggs.gnu.org with smtp (Exim 4.69) (envelope-from ) id 1OKe0N-0005Uu-36 for bug-coreutils@gnu.org; Fri, 04 Jun 2010 17:00:39 -0400 Received: (qmail invoked by alias); 04 Jun 2010 21:00:36 -0000 Received: from hex.aaisp.net.uk (EHLO ppp.zz) [90.155.53.9] by mail.gmx.com (mp-eu002) with SMTP; 04 Jun 2010 23:00:36 +0200 X-Authenticated: #48875277 X-Provags-ID: V01U2FsdGVkX1/AQLId4+bA0NciR4JDaTsyWIBeSScygYxghI50nj tZZsX/iJwd3Xn5 From: Davide Brini To: bug-coreutils@gnu.org Subject: Re: 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; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201006042149.09076.dave_br@gmx.com> X-Y-GMX-Trusted: 0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Spam-Score: -3.5 (---) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 04 Jun 2010 17:04:40 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.7 (----) 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. -- D. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 07 18:50:24 2010 Received: (at 6353-done) by debbugs.gnu.org; 7 Jun 2010 22:50:24 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLl9E-0004P9-89 for submit@debbugs.gnu.org; Mon, 07 Jun 2010 18:50:24 -0400 Received: from joseki.proulx.com ([216.17.153.58]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLl9C-0004P4-Dc for 6353-done@debbugs.gnu.org; Mon, 07 Jun 2010 18:50:22 -0400 Received: from dementia.proulx.com (dementia.proulx.com [192.168.230.115]) by joseki.proulx.com (Postfix) with ESMTP id 44F7421362; Mon, 7 Jun 2010 16:50:18 -0600 (MDT) Received: by dementia.proulx.com (Postfix, from userid 1000) id 3E4CF3CD899; Mon, 7 Jun 2010 16:50:18 -0600 (MDT) Date: Mon, 7 Jun 2010 16:50:18 -0600 From: Bob Proulx To: Darwin Gregory Subject: Re: bug#6353: cp and mv with single wild card argument acts as if multiple arguments were entered. Message-ID: <20100607225018.GA585@dementia.proulx.com> References: <20100604205215.GA21747@dementia.proulx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-Spam-Score: -2.4 (--) X-Debbugs-Envelope-To: 6353-done Cc: 6353-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.4 (--) Hi Darwin, I am happy that you are satisfied with the responses. I am going to close the bug ticket in the bug tracking system with this message. Bob From unknown Mon Jun 23 18:28:43 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 06 Jul 2010 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator