From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: Chris Puttick Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 May 2015 15:45:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 20603@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.14319638776954 (code B ref -1); Mon, 18 May 2015 15:45:06 +0000 Received: (at submit) by debbugs.gnu.org; 18 May 2015 15:44:37 +0000 Received: from localhost ([127.0.0.1]:49320 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuNDY-0001o5-8o for submit@debbugs.gnu.org; Mon, 18 May 2015 11:44:37 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37619) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuKig-0006IO-Pw for submit@debbugs.gnu.org; Mon, 18 May 2015 09:04:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuKia-00081I-LC for submit@debbugs.gnu.org; Mon, 18 May 2015 09:04:29 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:33646) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuKia-00081E-HO for submit@debbugs.gnu.org; Mon, 18 May 2015 09:04:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51116) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuKiV-0006Xy-1V for bug-coreutils@gnu.org; Mon, 18 May 2015 09:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuKiT-0007xp-Po for bug-coreutils@gnu.org; Mon, 18 May 2015 09:04:22 -0400 Received: from mail-ie0-x235.google.com ([2607:f8b0:4001:c03::235]:36319) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuKiT-0007xI-JA for bug-coreutils@gnu.org; Mon, 18 May 2015 09:04:21 -0400 Received: by iepj10 with SMTP id j10so21334276iep.3 for ; Mon, 18 May 2015 06:04:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=bDuQJc3GuT+jBKwNOPMH/d48oIfGAkTIY/DIdMm2hu0=; b=sf7UiljyXKqsvYCbxnkh+r9VJuU4Ebfh9ATgkGLit4IvzvCXbGpsVJTDrFbfOqksQY 01q461St8EzvqH5MOgApHZ2eZh7xV/PgUJbuXt/hGCkoijASUGHE+XyYugNJ8IPWFY9V SQ1hBB37wUc4edaEV9oOqgYa3fnwCw+iuubyfsJPGrm4auKKDpouuE+jK/lhKHPrpTXf yj4BR2iqsEqRRbOhIHJ86uZ+Iv+lqz5i+2KXgNpDTYYWo47tUc2qngohM8rMj87eUKfv 50+PvEWgKrBG/+HwxBBIP1rbedVMMLEJ+CaQhbS0GNs6YxRBh2WIBOSya4uIUbd1M9bZ KHRw== MIME-Version: 1.0 X-Received: by 10.107.7.84 with SMTP id 81mr3205604ioh.28.1431954260353; Mon, 18 May 2015 06:04:20 -0700 (PDT) Received: by 10.107.141.80 with HTTP; Mon, 18 May 2015 06:04:20 -0700 (PDT) Date: Mon, 18 May 2015 14:04:20 +0100 Message-ID: From: Chris Puttick Content-Type: text/plain; charset=UTF-8 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Mailman-Approved-At: Mon, 18 May 2015 11:44:35 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Hi In moment of tiredness issued a cp command similar to cp /path/to/files/* neglecting to add a destination (should have been ./) The files in the directory were 2 vdisks both ending .qcow2. No error message was generated and the apparent result of running the command is that the file whose name came first alphabetically was copied over the other. The installed OS on the machine was Ubuntu 12.04 and cp version 7.4. I can provide more details on request. Regards Chris -- @putt1ck putt1ck.blogspot.com http://twoten.is skype: putt1ck Opinions in this email are my own and may not reflect that of my clients, past employers, associates, friends, family, pets etc.. From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 May 2015 15:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Chris Puttick , 20603@debbugs.gnu.org Received: via spool by 20603-submit@debbugs.gnu.org id=B20603.14319645528069 (code B ref 20603); Mon, 18 May 2015 15:56:02 +0000 Received: (at 20603) by debbugs.gnu.org; 18 May 2015 15:55:52 +0000 Received: from localhost ([127.0.0.1]:49336 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuNOR-000264-Ae for submit@debbugs.gnu.org; Mon, 18 May 2015 11:55:51 -0400 Received: from mail5.vodafone.ie ([213.233.128.176]:39468) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuNOO-00025o-Ao for 20603@debbugs.gnu.org; Mon, 18 May 2015 11:55:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsYbAPgJWlVtTEto/2dsb2JhbABcgxCCbYFjxlqCUwKBNEwBAQEBAQGBC0EBAgKDXQEBBCMPAVYLDQEKAgIFFgsCAgkDAgECAUUGAQwIAQGILAG0SYVrng8BK4EhihmFDIJogUUFizyaJI8LI4N5PYJ3AQEB Received: from unknown (HELO localhost.localdomain) ([109.76.75.104]) by mail3.vodafone.ie with ESMTP; 18 May 2015 16:55:40 +0100 Message-ID: <555A0B7C.6090906@draigBrady.com> Date: Mon, 18 May 2015 16:55:40 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) tag 20603 notabug close 20603 stop On 18/05/15 14:04, Chris Puttick wrote: > Hi > > In moment of tiredness issued a cp command similar to > > cp /path/to/files/* > > neglecting to add a destination (should have been ./) > > The files in the directory were 2 vdisks both ending .qcow2. > > No error message was generated and the apparent result of running the > command is that the file whose name came first alphabetically was > copied over the other. > > The installed OS on the machine was Ubuntu 12.04 and cp version 7.4. > > I can provide more details on request. You were unlucky that the glob expanded to two files. With more files you would have gotten an error. However the expansion is done before cp executes, and so there is no opportunity to behave differently here. thanks, Pádraig From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: Chris Puttick Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 May 2015 16:01:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 20603@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.14319648178507 (code B ref -1); Mon, 18 May 2015 16:01:03 +0000 Received: (at submit) by debbugs.gnu.org; 18 May 2015 16:00:17 +0000 Received: from localhost ([127.0.0.1]:49340 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuNSg-0002D7-S9 for submit@debbugs.gnu.org; Mon, 18 May 2015 12:00:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33571) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuMMf-0000Tv-KV for submit@debbugs.gnu.org; Mon, 18 May 2015 10:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuMMU-0008Cv-Mj for submit@debbugs.gnu.org; Mon, 18 May 2015 10:49:52 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:60788) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuMMU-0008Cp-Kc for submit@debbugs.gnu.org; Mon, 18 May 2015 10:49:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuMMT-0008QS-CB for bug-coreutils@gnu.org; Mon, 18 May 2015 10:49:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuMMS-0008Bs-As for bug-coreutils@gnu.org; Mon, 18 May 2015 10:49:45 -0400 Received: from mail-ig0-x22f.google.com ([2607:f8b0:4001:c05::22f]:37536) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuMMS-0008Bj-5y for bug-coreutils@gnu.org; Mon, 18 May 2015 10:49:44 -0400 Received: by igbsb11 with SMTP id sb11so49730527igb.0 for ; Mon, 18 May 2015 07:49:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=0qrRJVy8ToZDtJNnxd7H5pWoGsfCHGAqg4j/zHTUBKw=; b=KgUApg3jdf9gjEYMbfDp+U6cEPVHTTVgPY8UGUnE4KPEEZnb5cCiR9InkYlDg5YEkj l2y9r4NrsKItiiXXj5x+tIdXLcL1sFLOxap2YSEJ/LxrvP4U1QxSaBNVL/EVMpFupA4J 8t9xI+V1YsoDk43sn/XJM/JklEZBCLhHINTfJE/QUxlhrbeHXnZWjVg5s/k6QV5vV2KG y13T8SnZb09UC05Ci4HTTY6rqyAJN4DhrEpmm4LBtUxDER+TqAfSdYoBZbNkFMZ/0NwZ k+gr3rtkis4DOiqvXL5jtYg//ur9+lZRXWfaCUzVrgp1/QNxLgiqlAockrFno5NUw6aI aHyQ== MIME-Version: 1.0 X-Received: by 10.50.43.196 with SMTP id y4mr14841754igl.14.1431960583517; Mon, 18 May 2015 07:49:43 -0700 (PDT) Received: by 10.107.141.80 with HTTP; Mon, 18 May 2015 07:49:43 -0700 (PDT) In-Reply-To: References: Date: Mon, 18 May 2015 15:49:43 +0100 Message-ID: From: Chris Puttick Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -4.0 (----) X-Mailman-Approved-At: Mon, 18 May 2015 12:00:12 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Follow up, reproducing: tested on openSuSE Factory Do: # mkdir test # echo "this is file 1" > test/file1 # touch test/file2 # cp test/* # cat test/file2 If there is a 3rd file in the directory you get an error: "cp: target =E2=80=98test/file3=E2=80=99 is not a directory" On 18 May 2015 at 14:04, Chris Puttick wrote: > Hi > > In moment of tiredness issued a cp command similar to > > cp /path/to/files/* > > neglecting to add a destination (should have been ./) > > The files in the directory were 2 vdisks both ending .qcow2. > > No error message was generated and the apparent result of running the > command is that the file whose name came first alphabetically was > copied over the other. > > The installed OS on the machine was Ubuntu 12.04 and cp version 7.4. > > I can provide more details on request. > > Regards > > Chris > > -- > @putt1ck > putt1ck.blogspot.com > http://twoten.is > skype: putt1ck > > Opinions in this email are my own and may not reflect that of my > clients, past employers, associates, friends, family, pets etc.. --=20 @putt1ck putt1ck.blogspot.com http://twoten.is skype: putt1ck Opinions in this email are my own and may not reflect that of my clients, past employers, associates, friends, family, pets etc.. From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: =?UTF-8?Q?P=C3=A1draig?= Brady Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 May 2015 17:01:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Chris Puttick , 20603@debbugs.gnu.org Received: via spool by 20603-submit@debbugs.gnu.org id=B20603.143196844613915 (code B ref 20603); Mon, 18 May 2015 17:01:03 +0000 Received: (at 20603) by debbugs.gnu.org; 18 May 2015 17:00:46 +0000 Received: from localhost ([127.0.0.1]:49356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuOPE-0003cJ-6f for submit@debbugs.gnu.org; Mon, 18 May 2015 13:00:45 -0400 Received: from mail4.vodafone.ie ([213.233.128.170]:48086) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuOPB-0003c3-OX for 20603@debbugs.gnu.org; Mon, 18 May 2015 13:00:42 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsYbAG4ZWlVtTEto/2dsb2JhbABcgxCCbYFjxlqCUwKBNEwBAQEBAQGBC0EBAgKDXQEBBCMPAVYLDQEKAgIFFgsCAgkDAgECAUUGAQwIAQGILAG0U4VrnhEBK4EhihmFDIJogUUFpWCPCyODeT2CdwEBAQ Received: from unknown (HELO localhost.localdomain) ([109.76.75.104]) by mail3.vodafone.ie with ESMTP; 18 May 2015 18:00:34 +0100 Message-ID: <555A1AB1.9050806@draigBrady.com> Date: Mon, 18 May 2015 18:00:33 +0100 From: =?UTF-8?Q?P=C3=A1draig?= Brady User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 References: In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 18/05/15 15:49, Chris Puttick wrote: > Follow up, reproducing: > > tested on openSuSE Factory > > Do: > > # mkdir test > # echo "this is file 1" > test/file1 > # touch test/file2 > # cp test/* > # cat test/file2 > > If there is a 3rd file in the directory you get an error: > > "cp: target ‘test/file3’ is not a directory" Note you can prompt before overwriting existing files like: cp -i file1 file2 cheers, Pádraig From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: Bob Proulx Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Mon, 18 May 2015 23:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Chris Puttick Cc: 20603@debbugs.gnu.org Received: via spool by 20603-submit@debbugs.gnu.org id=B20603.143199146115805 (code B ref 20603); Mon, 18 May 2015 23:25:02 +0000 Received: (at 20603) by debbugs.gnu.org; 18 May 2015 23:24:21 +0000 Received: from localhost ([127.0.0.1]:49471 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuUOS-00046r-PO for submit@debbugs.gnu.org; Mon, 18 May 2015 19:24:21 -0400 Received: from joseki.proulx.com ([216.17.153.58]:56076) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuUOQ-00046j-BW for 20603@debbugs.gnu.org; Mon, 18 May 2015 19:24:19 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id 86AFD21232; Mon, 18 May 2015 17:24:17 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id 5C77A2DC4F; Mon, 18 May 2015 17:24:17 -0600 (MDT) Date: Mon, 18 May 2015 17:24:17 -0600 From: Bob Proulx Message-ID: <20150518170933216742543@bob.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.23 (2014-03-12) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Chris Puttick wrote: > In moment of tiredness issued a cp command similar to > cp /path/to/files/* > neglecting to add a destination (should have been ./) > The files in the directory were 2 vdisks both ending .qcow2. Ouch! I am sorry for your loss. I hope you had backups. :-( > No error message was generated and the apparent result of running the > command is that the file whose name came first alphabetically was > copied over the other. There was no error message because as far as the computer was concerned it did exactly as you instructed it and no error occurred. You are apparently not aware that the shell reads your command line, parses it, expands it, and then the shell executes the resulting command. Many command line characters are "shell metacharacters". Search for that and you will find many references. When I say shell here I will assume the bash shell however this part applies to all of the Unix-like command line shells such as ksh, zsh, csh, sh and so forth. One of the file glob characters is the "*" character. (It is called a file glob because the star is expanded to match a glob of files.) Whenever you use a '*' in a command line that is an instruction to the shell. It tells the shell to list the files and match them and replace the star character with the list of matching file names. Try this exercise to understand a little bit about the '*' character and what the shell does. $ mkdir /tmp/junk $ cd /tmp/junk $ touch file1 $ echo * file1 $ touch file2 $ echo * file1 file2 $ touch file 3 $ echo * file1 file2 file3 $ echo *1 file1 $ echo *[23] file2 file3 As you can see the shell is replacing the '*' character with the files that were expanded which match it. And I threw in another couple of file expansions too just to help push the concept home. By this point you should know that your cp command had a '*' in the command line. The shell expanded that star. There were only two expansions. Therefore the shell invoked cp with two arguments. cp /path/to/files/file1 /path/to/files/file2 That is the command that cp was invoked with after the shell expanded the file globs on the command line. As far as the cp command is concerned it was given a command, cp executed the command, and the command was completed without error. The cp command has no way of knowing that you wanted to execute this command instead. cp /path/to/files/file1 /path/to/files/file2 ./ How could it? It can't. One command looks just the same as the other one to the cp command. None of the commands ever see the '*' character because it is expanded by the shell and replaced before the utility is invoked. Hope that expansion helps explain things. Bob From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: Chris Puttick Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 19 May 2015 05:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Bob Proulx Cc: 20603@debbugs.gnu.org Received: via spool by 20603-submit@debbugs.gnu.org id=B20603.143201287515931 (code B ref 20603); Tue, 19 May 2015 05:22:02 +0000 Received: (at 20603) by debbugs.gnu.org; 19 May 2015 05:21:15 +0000 Received: from localhost ([127.0.0.1]:49531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuZxq-00048r-28 for submit@debbugs.gnu.org; Tue, 19 May 2015 01:21:15 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:38514) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuZxl-00048a-Ly for 20603@debbugs.gnu.org; Tue, 19 May 2015 01:21:11 -0400 Received: by igcau1 with SMTP id au1so5810025igc.1 for <20603@debbugs.gnu.org>; Mon, 18 May 2015 22:21:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=oCfe6geAl7mJQPHGLnDvP30i14xS2HLj10zNbMh1dD4=; b=DX5wPHmXo0+2JJAHD0YgsKn0pvkm1TLiz6LGLixgIiw0a7H1BuhOWRmhEcaP9Co4ey j6/MSYry95MEfHjRqjobmyGF0tP+fSj4izldnuvSQYDYFuudQ4Pj0T68UObe6FVGry1z DY5iqUE8s2jaRKCqwt9txgVSOCqFzCQzz5eLWSxwD2EDL4EHVOM+LLCrcZW0ELA7mCM0 kIoXnG4UHNdtDgKJ4KLlreABpg0FlhehYk/x6f8xSfbcXkEul9s+xvuCjGRLRQTo63Fl zHKFDDvW2A3mxZjaUwdRDoNHvE8qB38+Ez80Z42DOhmmcbyvSxC7Zi10NZ3iOU0EYOTY t0HA== MIME-Version: 1.0 X-Received: by 10.42.50.81 with SMTP id z17mr3821096icf.57.1432012863828; Mon, 18 May 2015 22:21:03 -0700 (PDT) Received: by 10.107.141.80 with HTTP; Mon, 18 May 2015 22:21:03 -0700 (PDT) In-Reply-To: <20150518170933216742543@bob.proulx.com> References: <20150518170933216742543@bob.proulx.com> Date: Tue, 19 May 2015 06:21:03 +0100 Message-ID: From: Chris Puttick Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) The expansion & consequences of my typo understood! However, given the risks inherent in this edge case (directory only has 2 files in it) and the unlikelihood of someone wanting to change a directory containing 2 different files into a directory containing 2 identical but differently named files, it would be great if the cp command to check, when the source and destination directories are the same, the file count in that directory and issue a warning before continuing if the file count =2. I guess this would apply to others where the consequences of a similar typo would be bad, like mv. On 19 May 2015 at 00:24, Bob Proulx wrote: > Chris Puttick wrote: >> In moment of tiredness issued a cp command similar to >> cp /path/to/files/* >> neglecting to add a destination (should have been ./) >> The files in the directory were 2 vdisks both ending .qcow2. > > Ouch! I am sorry for your loss. I hope you had backups. :-( > >> No error message was generated and the apparent result of running the >> command is that the file whose name came first alphabetically was >> copied over the other. > > There was no error message because as far as the computer was > concerned it did exactly as you instructed it and no error occurred. > > You are apparently not aware that the shell reads your command line, > parses it, expands it, and then the shell executes the resulting > command. Many command line characters are "shell metacharacters". > Search for that and you will find many references. When I say shell > here I will assume the bash shell however this part applies to all of > the Unix-like command line shells such as ksh, zsh, csh, sh and so forth. > > One of the file glob characters is the "*" character. (It is called a > file glob because the star is expanded to match a glob of files.) > Whenever you use a '*' in a command line that is an instruction to the > shell. It tells the shell to list the files and match them and > replace the star character with the list of matching file names. Try > this exercise to understand a little bit about the '*' character and > what the shell does. > > $ mkdir /tmp/junk > $ cd /tmp/junk > $ touch file1 > $ echo * > file1 > $ touch file2 > $ echo * > file1 file2 > $ touch file 3 > $ echo * > file1 file2 file3 > $ echo *1 > file1 > $ echo *[23] > file2 file3 > > As you can see the shell is replacing the '*' character with the files > that were expanded which match it. And I threw in another couple of > file expansions too just to help push the concept home. > > By this point you should know that your cp command had a '*' in the > command line. The shell expanded that star. There were only two > expansions. Therefore the shell invoked cp with two arguments. > > cp /path/to/files/file1 /path/to/files/file2 > > That is the command that cp was invoked with after the shell expanded > the file globs on the command line. As far as the cp command is > concerned it was given a command, cp executed the command, and the > command was completed without error. > > The cp command has no way of knowing that you wanted to execute this > command instead. > > cp /path/to/files/file1 /path/to/files/file2 ./ > > How could it? It can't. One command looks just the same as the other > one to the cp command. None of the commands ever see the '*' > character because it is expanded by the shell and replaced before the > utility is invoked. > > Hope that expansion helps explain things. > > Bob -- @putt1ck putt1ck.blogspot.com http://twoten.is skype: putt1ck Opinions in this email are my own and may not reflect that of my clients, past employers, associates, friends, family, pets etc.. From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: Bernhard Voelker Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 19 May 2015 06:03:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Chris Puttick , Bob Proulx Cc: 20603@debbugs.gnu.org Received: via spool by 20603-submit@debbugs.gnu.org id=B20603.143201538219903 (code B ref 20603); Tue, 19 May 2015 06:03:03 +0000 Received: (at 20603) by debbugs.gnu.org; 19 May 2015 06:03:02 +0000 Received: from localhost ([127.0.0.1]:49538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuacH-0005As-62 for submit@debbugs.gnu.org; Tue, 19 May 2015 02:03:01 -0400 Received: from mout.kundenserver.de ([212.227.126.130]:52981) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1YuacE-0005Af-M5 for 20603@debbugs.gnu.org; Tue, 19 May 2015 02:02:59 -0400 Received: from [192.168.101.10] ([217.87.213.182]) by mrelayeu.kundenserver.de (mreue005) with ESMTPSA (Nemesis) id 0Lr6Jj-1ZOxQG38AV-00ebPK; Tue, 19 May 2015 08:02:51 +0200 Message-ID: <555AD20A.4070207@bernhard-voelker.de> Date: Tue, 19 May 2015 08:02:50 +0200 From: Bernhard Voelker User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 References: <20150518170933216742543@bob.proulx.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Do+4eLWiTAUYitXj2kxurV35Di8eejpy6GIX+mtGFyhEtWFgQH+ ce9xDYDO4ZAKFa6k8+6fG4FozX4+7VHtGNtnO2Xk5JhIcOIiHKH+FUYKwlB6kgKg7gjTYpY fDIi9olBavtztgowdOpsJyEDq2k1+IuUkcvdVys/8Dr6gVGj7PzyYDFNPe6OLvj5rkVKKG1 Wv9VQhYN7HftFuiJyoSGA== X-UI-Out-Filterresults: notjunk:1; X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On 05/19/2015 07:21 AM, Chris Puttick wrote: > The expansion & consequences of my typo understood! However, given the > risks inherent in this edge case (directory only has 2 files in it) > and the unlikelihood of someone wanting to change a directory > containing 2 different files into a directory containing 2 identical > but differently named files, it would be great if the cp command to > check, when the source and destination directories are the same, the > file count in that directory and issue a warning before continuing if > the file count =2. If there was such a check, a warning wouldn't have helped you - as the command would have proceeded with overwriting the file anyway. Second, how should cp know when the user really wants to do that? We'd have to special case this, too. Third, such a check would be racy. After all, we won't add such a construct. cp(1) performed exactly the option you told it to do. But there is other help: I rather suggest that you to consider using the -n or -i option: -i, --interactive prompt before overwrite (overrides a previous -n option) -n, --no-clobber do not overwrite an existing file (overrides a previous -i option) You can even set an alias for it like this in your profile: alias cp='\cp -n' Or, if in doubt, pass the command line to echo before executing, by which you would see what would happen: $ echo cp /some/dir/file* cp /some/dir/file1 /some/dir/file2 Have a nice day, Berny From unknown Wed Jun 25 09:11:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#20603: Possible bug in cp Resent-From: Bob Proulx Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Tue, 19 May 2015 07:14:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20603 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: Chris Puttick Cc: 20603@debbugs.gnu.org Received: via spool by 20603-submit@debbugs.gnu.org id=B20603.143201964026408 (code B ref 20603); Tue, 19 May 2015 07:14:01 +0000 Received: (at 20603) by debbugs.gnu.org; 19 May 2015 07:14:00 +0000 Received: from localhost ([127.0.0.1]:49543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yubix-0006rr-QZ for submit@debbugs.gnu.org; Tue, 19 May 2015 03:14:00 -0400 Received: from joseki.proulx.com ([216.17.153.58]:58039) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Yubiu-0006ri-F9 for 20603@debbugs.gnu.org; Tue, 19 May 2015 03:13:57 -0400 Received: from hysteria.proulx.com (hysteria.proulx.com [192.168.230.119]) by joseki.proulx.com (Postfix) with ESMTP id DA0C821232; Tue, 19 May 2015 01:13:54 -0600 (MDT) Received: by hysteria.proulx.com (Postfix, from userid 1000) id A5A572DC4F; Tue, 19 May 2015 01:13:54 -0600 (MDT) Date: Tue, 19 May 2015 01:13:54 -0600 From: Bob Proulx Message-ID: <20150519004824983983525@bob.proulx.com> References: <20150518170933216742543@bob.proulx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Chris Puttick wrote: > The expansion & consequences of my typo understood! However, given the > risks inherent in this edge case (directory only has 2 files in it) > and the unlikelihood of someone wanting to change a directory > containing 2 different files into a directory containing 2 identical > but differently named files, it would be great if the cp command to > check, when the source and destination directories are the same, the > file count in that directory and issue a warning before continuing if > the file count =2. So I think you are telling me that if I were to do this: mkdir /tmp/junk touch /tmp/junk/file1 /tmp/junk/file2 cp /tmp/junk/file1 /tmp/junk/file2 You are suggesting that the cp command above would fail in the above situation? I am sorry but that is much to specific of something to single out as a special case in the code. And it would fail in most perfectly valid situations. Like the above. The above is perfectly valid and should not fail. Additionally I often do things like this for example: cp foo.conf foo.conf.bak edit foo.conf cp foo.conf.bak foo.conf It would be wrong if the above were to fail. Additionally what about this case: mkdir /tmp/junk && cd /tmp/junk touch one.txt two.txt touch README cp *.txt The shell will expand "cp *.txt" to be "cp one.txt two.txt". The file count for the directory will be three and therefore the suggested special case rule would not be triggered. I daresay that the suggested special case rule would only very rarely be triggered when it would help and would be a false positive for most valid cases. I am sorry that you had a bad experience with file glob expansion. But so far the suggestions for improvement hasn't made a compelling argument yet. Bob From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 22:21:56 2018 Received: (at control) by debbugs.gnu.org; 23 Oct 2018 02:21:56 +0000 Received: from localhost ([127.0.0.1]:36768 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEmKS-0000cV-6Z for submit@debbugs.gnu.org; Mon, 22 Oct 2018 22:21:56 -0400 Received: from mail-it1-f170.google.com ([209.85.166.170]:51548) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEmKQ-0000cG-MD for control@debbugs.gnu.org; Mon, 22 Oct 2018 22:21:54 -0400 Received: by mail-it1-f170.google.com with SMTP id 74-v6so120765itw.1 for ; Mon, 22 Oct 2018 19:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:message-id:date:user-agent:mime-version:content-language :content-transfer-encoding; bh=X6w8pkfWDJDqMshvvUC3PbcEd+1oS9NOF6HyB66vTnE=; b=TpDZm516AUtqOAxKCnSaeyNZUPeS1i6JSkE6HIyFdd+HffekcYcWwWOz/M3VsqmMkY RNdQX329HT/YZlc1RHR3eRxPPqjDGe7qnCuKSkT7sZ2lEftSitxe08rphBcNB/29ngPW 8GLMhVzgEXiafCRR02OJigQFeLAqwGbb6yFqtunEfJkzKyNQWF+EoUcmdc7oVKgLwV+i RGhdR7q3jK/uOs2yNipHveWgbg3Vqv2yXPXqeut1HzPBB2d+u5Vc+d0pG+Fbr9fFzUxs GLDCHxr6sY5iiP7A1DbAjbE82N2LJJhzjdD5btVE/SoLGQN31d8fo0hIoivD2wjMLh3C WREQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=X6w8pkfWDJDqMshvvUC3PbcEd+1oS9NOF6HyB66vTnE=; b=uGapkIj1Z7ZA3gU9b+oqqPFHKnnhlWNB+3qBueuHf4ZN76S9FVtp8lQwRAx3SD85wH OgOTtjS428L6ta/zDTfrMODDYZW9iwh+9bhDbKMkqijPn5YDXuRwm6CSlF3WWv5g9KKN ybhlWUkOeRrWgvsTEG62ouWqrJsYQUoLR9UxKGIgAK8Ew0Nr9lZMowHoqq5wwyK7815D rY2RykieYgxpnaX2tm5dxl5E42NunGIxKjdarNjR39jomz6O7FwZfDRoaZc6Lgz4CVPq AVpfWMLOGZG4cDFZtTI0VdiL52HN0zmwQzNsQ8PMpSEVzht7ueJjrgrXzs8lIbxk7suo ii3Q== X-Gm-Message-State: ABuFfoi2hWinzkPXFEa2tcHlHM5S3MfZIIegxZZNqYivD2Bzzo7koAZ7 lqwe7/756R2wBo/SsaYfIJwcxEvN X-Google-Smtp-Source: ACcGV616d+d4Y5GeX3UD2zNwRE4tMAdPyn2XY2Z/lsZQx0WFpsVobHh8OIlfR3KiMDkkuG4MZqYltA== X-Received: by 2002:a05:660c:b03:: with SMTP id f3mr11299330itk.60.1540261308545; Mon, 22 Oct 2018 19:21:48 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id g73-v6sm39126itg.37.2018.10.22.19.21.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 19:21:47 -0700 (PDT) To: control@debbugs.gnu.org From: Assaf Gordon Message-ID: <2f343274-ca9c-1a58-4f23-92a2b6a85148@gmail.com> Date: Mon, 22 Oct 2018 20:21:45 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 2.0 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: tags 20603 notabug close 20603 [...] Content analysis details: (2.0 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.166.170 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.166.170 listed in list.dnswl.org] 1.8 MISSING_SUBJECT Missing Subject: header 0.2 NO_SUBJECT Extra score for no subject X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) tags 20603 notabug close 20603