From: Glenn Morris <rgm@gnu.org>
To: Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
Cc: bug-gnu-emacs@gnu.org
Subject: Re: shell-mode flakey
Date: Tue, 18 Dec 2007 19:54:09 -0500 [thread overview]
Message-ID: <sa1w9jld1q.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <m3k5ncrn57.fsf@tfkp07.physik.uni-erlangen.de> (Roland Winkler's message of "Tue, 18 Dec 2007 17:19:32 +0100")
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 "<command> && rm" works
## as expected.
alias rm='_rmfunc="$-" && set -f && rmfunc "$_rmfunc"'
next prev parent reply other threads:[~2007-12-19 0:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87zlxfhztn.fsf@windlord.stanford.edu>
2007-12-18 5:24 ` shell-mode flakey [was Re: message-confirm-send] jidanni
[not found] ` <mailman.5147.1197955487.18990.bug-gnu-emacs@gnu.org>
2007-12-18 16:19 ` shell-mode flakey Roland Winkler
2007-12-18 19:51 ` Andreas Röhler
2007-12-19 0:31 ` Miles Bader
2007-12-19 0:54 ` Glenn Morris [this message]
2007-12-19 2:22 ` Russ Allbery
[not found] ` <mailman.5185.1198024311.18990.bug-gnu-emacs@gnu.org>
2007-12-19 16:25 ` Sven Joachim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sa1w9jld1q.fsf@fencepost.gnu.org \
--to=rgm@gnu.org \
--cc=Roland.Winkler@physik.uni-erlangen.de \
--cc=bug-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.