From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12118 invoked by alias); 28 Jan 2014 16:51:54 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18377 Received: (qmail 15851 invoked from network); 28 Jan 2014 16:51:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 From: Bart Schaefer Message-id: <140128085131.ZM21235@torch.brasslantern.com> Date: Tue, 28 Jan 2014 08:51:31 -0800 In-reply-to: Comments: In reply to Florian Hofmann "Is there a RM_TILDE_WAIT?" (Jan 27, 1:18pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Is there a RM_TILDE_WAIT? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Jan 27, 1:18pm, Florian Hofmann wrote: } } I know this probably happen doesn't happen often (at least this is the } first time I did this in 10+ years of Linux usage), but to prevent this } from happening "rm -rf ~" just trigger the the same prompt as "rm -rf *", } shouldn't it? The warning on "*" happens when it appears anywhere in the argument list where "rm" is the command word. I mention this just in case what you really want is a delay when the -r and -f options are used together. The latter can easily be done with a function; the only magic part of RM_STAR_WAIT is that it tests the command line before globbing has a chance to expand the "*". Similarly a function can test whether any of the arguments is $HOME without needing to know that it was expanded from a tilde. Here is such a function. I'm sure you can see how to tweak it to your liking, e.g., it could detect -i/--interactive and skip the prompt, etc. For those pedantic types who would point out that this might prompt as a result of files named with a leading hyphen, I'll just note that the scan done by the internal RM_STAR handling is no more sophisticated. rm() { integer i f r h for ((i = 1; i <= ARGC; ++i)) do if [[ $argv[i] = $HOME ]] then ((h++)) elif [[ $argv[i] != --* ]] then [[ $argv[i] = -*r* ]] && ((r++)) [[ $argv[i] = -*f* ]] && ((f++)) else [[ $argv[i] = --recursive ]] && ((r++)) [[ $argv[i] = --force ]] && ((f++)) fi done if (( r && f && h )) && [[ -o RM_STAR_WAIT ]] then print -u2 "zsh: sure you want to recursively delete $HOME ?" print -u2 "(waiting ten seconds)" sleep 10 read -q '? [y/n]?' || return 1 fi command rm "$@" }