bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#37686: Feature request: flag to not remove any files if any argument


From: L A Walsh
Subject: 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
User-agent: Thunderbird

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.







reply via email to

[Prev in Thread] Current Thread [Next in Thread]