GNU bug report logs - #61105
cp/mv: want a fatal --no-clobber

Previous Next

Package: coreutils;

Reported by: Mike Frysinger <vapier <at> gentoo.org>

Date: Fri, 27 Jan 2023 20:53:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#61105: closed (cp/mv: want a fatal --no-clobber)
Date: Tue, 31 Jan 2023 16:57:01 +0000
[Message part 1 (text/plain, inline)]
Your message dated Tue, 31 Jan 2023 08:55:48 -0800
with message-id <b16b0403-2064-06d2-234c-7121d38374c4 <at> cs.ucla.edu>
and subject line Re: bug#61105: cp/mv: want a fatal --no-clobber
has caused the debbugs.gnu.org bug report #61105,
regarding cp/mv: want a fatal --no-clobber
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
61105: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61105
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Mike Frysinger <vapier <at> gentoo.org>
To: bug-coreutils <at> gnu.org
Subject: cp/mv: want a fatal --no-clobber
Date: Fri, 27 Jan 2023 15:52:09 -0500
[Message part 3 (text/plain, inline)]
i've been under the mistaken assumption that the -n/--no-clobber option exits
non-zero when the target exists, but someone pointed out to me recently that
it silently ignores existing files.  can we get a setting to control this ?

basically i've been writing things like:
if ! cp -n foo bar; then
  ... error out because bar already exists, or otherwise failed ...
fi

when really i need to write:
if [ -e bar ] || ! cp foo bar; then
  ... error out ...
fi
-mike
[signature.asc (application/pgp-signature, inline)]
[Message part 5 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pádraig Brady <P <at> draigBrady.com>,
 Mike Frysinger <vapier <at> gentoo.org>
Cc: 61105-done <at> debbugs.gnu.org
Subject: Re: bug#61105: cp/mv: want a fatal --no-clobber
Date: Tue, 31 Jan 2023 08:55:48 -0800
[Message part 6 (text/plain, inline)]
On 2023-01-30 13:35, Pádraig Brady wrote:
> This is a good observation.
> Also the current "skip" functionality of coreutils cp -n
> is already catered for with the --update option.

For consistency, there too the exit status should reflect whether the cp 
action was done.

I installed the attached patch to implement this; comments welcome. In 
the meantime I'm boldly closing the bug report.
[0001-cp-ln-mv-when-skipping-exit-with-nonzero-status.patch (text/x-patch, attachment)]

This bug report was last modified 2 years and 113 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.