From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: Re: shell-mode flakey Date: Tue, 18 Dec 2007 19:54:09 -0500 Message-ID: References: <87zlxfhztn.fsf@windlord.stanford.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1198025666 19071 80.91.229.12 (19 Dec 2007 00:54:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 19 Dec 2007 00:54:26 +0000 (UTC) Cc: bug-gnu-emacs@gnu.org To: Roland Winkler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 19 01:54:38 2007 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1J4nCm-0001N5-Ib for geb-bug-gnu-emacs@m.gmane.org; Wed, 19 Dec 2007 01:54:36 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J4nCT-0003XR-9T for geb-bug-gnu-emacs@m.gmane.org; Tue, 18 Dec 2007 19:54:17 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1J4nCO-0003XM-DY for bug-gnu-emacs@gnu.org; Tue, 18 Dec 2007 19:54:12 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J4nCN-0003XA-2T for bug-gnu-emacs@gnu.org; Tue, 18 Dec 2007 19:54:12 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J4nCM-0003X7-VH for bug-gnu-emacs@gnu.org; Tue, 18 Dec 2007 19:54:10 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J4nCM-0004G5-IK for bug-gnu-emacs@gnu.org; Tue, 18 Dec 2007 19:54:10 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.60) (envelope-from ) id 1J4nCL-0000Ks-He; Tue, 18 Dec 2007 19:54:09 -0500 X-Spook: plutonium NWO Ortega fraud CipherTAC-2000 Bosnia X-Ran: d^h_y~w`yF%N6^/2la!Kpn~zQB5qn@+qBMv>DR]>oePQ*>B,d(RDS (Roland Winkler's message of "Tue, 18 Dec 2007 17:19:32 +0100") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:17191 Archived-At: Roland Winkler wrote: > When I discussed this some time ago with one of the bash > maintainers, he said that he had just recovered all files of a > colleague who had typed "rm foo *" instead of "rm foo*". For those > and only those cases I'd like to have a reliable interactive query > before rm will do its job. Totally off-topic, but here's what I use for this kind of thing in bash. Uses an alias + a function. It occasionally chokes on odd characters in filenames, but otherwise works for me. ## Implement an equivalent of tcsh's 'rmstar'. ## After gnu.bash.bug: FRIEDMAN.93Mar1070341@nutrimat.gnu.ai.mit.edu function rmfunc() { unset _rmfunc [ $# -lt 2 ] && { echo "rm: too few arguments" return 1 } local noglob case $1 in *f*) noglob=t ;; esac shift ## Glob expansion was on. if [ ! "$noglob" ]; then set +f # reactivate glob expansion local arg star dir input for arg; do star= case "$arg" in '*'|*/'*'|*/'*'/*) star=t ;; esac [ $star ] || continue dir=${arg%/*} [ "$dir" = "$arg" ] && dir=. while : ; do echo -n "Remove all files in $dir [yn"\!"]? " read input case $input in y) break 1 ;; n) return 1 ;; '!') break 2 ;; *) echo "Please answer with one of y, n or "\! ;; esac done done # $arg set -f ## Escape [ #\t${}()]. IFS=$'\n' set -- $(for arg; do echo "$arg" done | sed -e 's/\([ '$'\t''${}()#]\)/\\\1/g') [ "$noglob" ] || set +f ## Conflict here. Need quotes to handle names ## with spaces, yet quotes prevents glob expansion. ## Need eval for glob expansion. eval command rm "$@" else # glob expansion was off command rm "$@" fi } # function rmfunc ## Need to prevent glob expansion before passing args to rmfunc. ## Note use "&&" rather than ";" so that " && rm" works ## as expected. alias rm='_rmfunc="$-" && set -f && rmfunc "$_rmfunc"'