GNU bug report logs - #37686
Feature request: flag to not remove any files if any argument doesn't exist or is a directory

Previous Next

Package: coreutils;

Reported by: Mark Friedenbach <mark <at> friedenbach.org>

Date: Wed, 9 Oct 2019 21:59:02 UTC

Severity: wishlist

Full log


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

From: L A Walsh <coreutils <at> tlinx.org>
To: Mark Friedenbach <mark <at> friedenbach.org>
Cc: 37686 <at> debbugs.gnu.org
Subject: Re: bug#37686: Feature request: flag to not remove any files if any
 argument doesn't exist or is a directory
Date: Mon, 14 Oct 2019 12:35:11 -0700
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.






This bug report was last modified 5 years and 311 days ago.

Previous Next


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