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: Mike Frysinger <vapier <at> gentoo.org>
To: 61105 <at> debbugs.gnu.org
Subject: bug#61105: cp/mv: want a fatal --no-clobber
Date: Fri, 27 Jan 2023 15:52:09 -0500
[Message part 1 (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)]

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

Previous Next


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