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


Message #11 received at 61105 <at> debbugs.gnu.org (full text, mbox):

From: Mike Frysinger <vapier <at> gentoo.org>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: 61105 <at> debbugs.gnu.org
Subject: Re: bug#61105: cp/mv: want a fatal --no-clobber
Date: Fri, 27 Jan 2023 19:22:58 -0500
[Message part 1 (text/plain, inline)]
On 27 Jan 2023 23:59, Pádraig Brady wrote:
> On 27/01/2023 20:52, Mike Frysinger wrote:
> > 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
> 
> The above is racy if the file is created between the test and the cp.

yes, that's why i want to only use cp :)

although if i was super concerned about TOCTOU races, i wouldn't be using
shell in the first place
-mike
[signature.asc (application/pgp-signature, inline)]

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.