GNU logs - #37686, boring messages


Message sent to bug-coreutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#37686: Feature request: flag to not remove any files if any argument doesn't exist or is a directory
Resent-From: Mark Friedenbach <mark@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-coreutils@HIDDEN
Resent-Date: Wed, 09 Oct 2019 21:59:02 +0000
Resent-Message-ID: <handler.37686.B.157065829513111 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 37686
X-GNU-PR-Package: coreutils
X-GNU-PR-Keywords: 
To: 37686 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-coreutils@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.157065829513111
          (code B ref -1); Wed, 09 Oct 2019 21:59:02 +0000
Received: (at submit) by debbugs.gnu.org; 9 Oct 2019 21:58:15 +0000
Received: from localhost ([127.0.0.1]:54318 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iIJyF-0003PI-VG
	for submit <at> debbugs.gnu.org; Wed, 09 Oct 2019 17:58:15 -0400
Received: from lists.gnu.org ([209.51.188.17]:38789)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mark@HIDDEN>) id 1iIJ6C-00085J-O8
 for submit <at> debbugs.gnu.org; Wed, 09 Oct 2019 17:02:21 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:43270)
 by lists.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <mark@HIDDEN>) id 1iIJ6A-0004Im-Kl
 for bug-coreutils@HIDDEN; Wed, 09 Oct 2019 17:02:19 -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 autolearn=disabled
 version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <mark@HIDDEN>) id 1iIJ66-0005Xw-VA
 for bug-coreutils@HIDDEN; Wed, 09 Oct 2019 17:02:16 -0400
Received: from mail-oi1-x231.google.com ([2607:f8b0:4864:20::231]:32931)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <mark@HIDDEN>)
 id 1iIJ66-0005Vt-Hu
 for bug-coreutils@HIDDEN; Wed, 09 Oct 2019 17:02:14 -0400
Received: by mail-oi1-x231.google.com with SMTP id a15so3030581oic.0
 for <bug-coreutils@HIDDEN>; Wed, 09 Oct 2019 14:02:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=friedenbach-org.20150623.gappssmtp.com; s=20150623;
 h=mime-version:from:date:message-id:subject:to;
 bh=fjAQ7VWIV0AheGkaeLI0QlSV1pZSoRBjZZub/xjSrG8=;
 b=N4wJEIYuWMnRi2oSxE85S+X3Or8H797Z5xIoPB/9dX/ouLl6xG0R95XtOUBLvXP++9
 pBhbC6hWbM0g0ODVWhW0gEoh+IIIgp/neomn/JGjdFITMYDLiLnSOYwfPQJmN6DcdBaL
 7h5aVejy2moxd4NDAT+9PiVNASZ1aNLGMUem1bOw4qnE5bSnNpC0EQuG3B2MrtHrOmYO
 RQlqRVtbRSMG/by6M7+IFQx8ervrSbLbRFMpEyx1LMD1JXnnGnm2uyBTYJybPvvDgLgB
 g+b0gY2ZbXc0hEjw3m+v75YKhqwnb3jiUcCJ2gNqmq4J7dThOYxxJASNj7M2CXQJ/J1s
 TwBA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=fjAQ7VWIV0AheGkaeLI0QlSV1pZSoRBjZZub/xjSrG8=;
 b=Ib+ICK9KQqFYtZKIybFqx/CmbYptf6e3mwkh9H2sYZkaXh0NSedvte9QuzrTa5wkOl
 qwlDUh1dmBHNMs7YfRlmkNLwRWQZVdovAEUQtOcURrUEcwxRcQ9dIMDvO5taefwhbwDn
 9DWnSwIdbeaj/EWfkznirkUz9jWIlPc+0wJkXEt3ycXOEC1HNMlWgAomJL4QrunxFY2w
 v2cgMGPahN2U30LPbGUK9b+l4HyJK085eP3zYVqtrDwjCBDEClZxkJ5YJkeS6zFYZQaE
 xb1hfn+J5N5H+EW5pKnYHHZT0Ziun8AvbxfPJ0d7ZW2UWSde56DuwEK8Y4v6bjpx4irE
 qYnw==
X-Gm-Message-State: APjAAAUjY3G4hnxuWgAM0IkacGCjmyk4zr7ZuAFyqFeZQNexyD1Y8lC0
 kWPmohX/5/kwRVj5I3QpRGTpPo7iYyqTeKWsWH5TRh2GTsQ=
X-Google-Smtp-Source: APXvYqy/8LMdBkGuqoPCEpANHVur7yT7650U9J6kKneBapnkXe1ED0WCvZ7f7cxSSyV41NrNYl1MLDl7jIirp3+WfxI=
X-Received: by 2002:a54:4e83:: with SMTP id c3mr4317884oiy.170.1570654928165; 
 Wed, 09 Oct 2019 14:02:08 -0700 (PDT)
MIME-Version: 1.0
From: Mark Friedenbach <mark@HIDDEN>
Date: Wed, 9 Oct 2019 14:01:57 -0700
Message-ID: <CAOG=w-ue4=KnNPGyegGpkZ-F7x1aO1c-YhmMgRjuqgZBTLp6BQ@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::231
X-Spam-Score: -2.3 (--)
X-Mailman-Approved-At: Wed, 09 Oct 2019 17:58:11 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

I have a persistent problem that has caused me serious trouble in the
past: I mixup 'rm' and 'mv'. I suspect this is because on my keyboard
they are typed with the same fingers and muscle memory kicks in,
especially if I just typed the other command recently.

In any case something like "mv oldname newname" can be easily undone,
but "rm oldname newname" cannot. On my version of coreutils "rm
oldname newname" will report:

    rm: cannot remove 'newname': No such file or directory

...but it deletes "newname" anyway! The same goes for trying to move a
file into a directory, "rm filename dirname" which reports:

    rm: cannot remove 'dirname': Is a directory

...after deleting "filename". I have lost data on multiple occasions
this way. Today I went searching for an argument to add to 'rm' via an
alias to prevent this behavior and was very surprised to find there is
none.

There ought to be an option for GNU rm, let's call it '-n' or
'--no-clobber' but it could be named differently, which makes rm's
behavior all-or-nothing. If any errors which can be checked for
upfront are encountered (named file does not exist, file name
specifies a directory, etc.) then it aborts without doing anything.
Thus the expected behavior would be:

    $ alias rm='rm -n'
    $ ls
    $ touch filename
    $ ls
    filename
    $ rm filename newname
    rm: cannot remove 'newname': No such file or directory
    rm: aborting
    $ ls
    filename
    $ mkdir dirname
    dirname  filename
    $ rm filename dirname
    rm: cannot remove 'dirname': Is a directory
    rm: aborting
    $ ls
    dirname  filename
    $ rm -f filename dirname
    rm: cannot remove 'dirname': Is a directory
    $ ls
    dirname  filename

Adding '-f' / '--force' overrides this option:

    $ ls
    dirname  filename
    $ rm -f filename dirname
    rm: cannot remove 'dirname': Is a directory
    $ ls
    dirname
    $ rm -rf filename dirname
    rm: cannot remove 'filename': No such file or directory
    $ ls
    $




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Mark Friedenbach <mark@HIDDEN>
Subject: bug#37686: Acknowledgement (Feature request: flag to not remove
 any files if any argument doesn't exist or is a directory)
Message-ID: <handler.37686.B.157065829513111.ack <at> debbugs.gnu.org>
References: <CAOG=w-ue4=KnNPGyegGpkZ-F7x1aO1c-YhmMgRjuqgZBTLp6BQ@HIDDEN>
X-Gnu-PR-Message: ack 37686
X-Gnu-PR-Package: coreutils
Reply-To: 37686 <at> debbugs.gnu.org
Date: Wed, 09 Oct 2019 21:59:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-coreutils@HIDDEN

If you wish to submit further information on this problem, please
send it to 37686 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
37686: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D37686
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-coreutils@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#37686: Feature request: flag to not remove any files if any argument doesn't exist or is a directory
Resent-From: L A Walsh <coreutils@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-coreutils@HIDDEN
Resent-Date: Mon, 14 Oct 2019 19:36:02 +0000
Resent-Message-ID: <handler.37686.B37686.157108171826558 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 37686
X-GNU-PR-Package: coreutils
X-GNU-PR-Keywords: 
To: Mark Friedenbach <mark@HIDDEN>
Cc: 37686 <at> debbugs.gnu.org
Received: via spool by 37686-submit <at> debbugs.gnu.org id=B37686.157108171826558
          (code B ref 37686); Mon, 14 Oct 2019 19:36:02 +0000
Received: (at 37686) by debbugs.gnu.org; 14 Oct 2019 19:35:18 +0000
Received: from localhost ([127.0.0.1]:41725 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1iK67i-0006uI-96
	for submit <at> debbugs.gnu.org; Mon, 14 Oct 2019 15:35:18 -0400
Received: from ishtar.tlinx.org ([173.164.175.65]:56794
 helo=Ishtar.sc.tlinx.org) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <coreutils@HIDDEN>) id 1iK67g-0006u5-LN
 for 37686 <at> debbugs.gnu.org; Mon, 14 Oct 2019 15:35:17 -0400
Received: from [192.168.3.12] (Athenae [192.168.3.12])
 by Ishtar.sc.tlinx.org (8.14.7/8.14.4/SuSE Linux 0.8) with ESMTP id
 x9EJZBQs055088; Mon, 14 Oct 2019 12:35:13 -0700
Message-ID: <5DA4CDEF.2070801@HIDDEN>
Date: Mon, 14 Oct 2019 12:35:11 -0700
From: L A Walsh <coreutils@HIDDEN>
User-Agent: Thunderbird
MIME-Version: 1.0
References: <CAOG=w-ue4=KnNPGyegGpkZ-F7x1aO1c-YhmMgRjuqgZBTLp6BQ@HIDDEN>
In-Reply-To: <CAOG=w-ue4=KnNPGyegGpkZ-F7x1aO1c-YhmMgRjuqgZBTLp6BQ@HIDDEN>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.4 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 2019/10/09 14:01, Mark Friedenbach wrote:
> I have a persistent problem that has caused me serious trouble in the
> past: I mixup 'rm' and 'mv'. I suspect this is because on my keyboard
> they are typed with the same fingers and muscle memory kicks in,
> especially if I just typed the other command recently.
>   
rm () {
  if [[ -t 0 ]]; then echo >&2 Disallowed;return 1; fi
  command "$FUNCNAME" "$@"
}
mv () {
  if [[ -t 0 ]]; then echo >&2 Disallowed;return 1; fi
  command "$FUNCNAME" "$@"
}
alias move='</dev/null mv'
alias remove='</dev/null rm'


How about something _like_ the above (spur of the moment idea,
written in 'bash'...

Interactively, you type 'move' or 'remove'
(or whatever you want to name them). But scripts you run
 won't be affected.

Might have to adjust for your use case, but might protect against
most cases.

Nightly backups also help prevent catastrophic problems.

At the same time, with functions or aliases, you could test for
the existence of the arguments before actually executing them.







Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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