unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* shell-mode flakey [was Re: message-confirm-send]
       [not found] <87zlxfhztn.fsf@windlord.stanford.edu>
@ 2007-12-18  5:24 ` jidanni
       [not found] ` <mailman.5147.1197955487.18990.bug-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 7+ messages in thread
From: jidanni @ 2007-12-18  5:24 UTC (permalink / raw)
  To: ding; +Cc: bug-gnu-emacs

RussA> I consider the rm -i alias to be useless.

Yeah well homeboy consider the case of emacs shell-mode as it offers
line buffering vs. character buffering, ideal for transpacific site
administration.

As one can not be exactly sure if "rm bla*" got sent intact as
sometimes has been my experience (bits of prompt sent, bits of command
not sent, but what can you demand it this cut and paste world), it's
nice to have the remote side ask you "are you sure?".

Indeed, even if I was using xterm, you never know what bumping the
mouse the wrong way might send from the current clipboard. Maybe SPACE
RETURN just when the cursor was in the wrong spot.

And of course for we Geritol clubbers, what if one becomes deceased
and one's chin hits SPC and nose hits RET. Do you want to be
remembered by your community club as that guy who deleted all the
files?




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: shell-mode flakey
       [not found] ` <mailman.5147.1197955487.18990.bug-gnu-emacs@gnu.org>
@ 2007-12-18 16:19   ` Roland Winkler
  2007-12-18 19:51     ` Andreas Röhler
                       ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Roland Winkler @ 2007-12-18 16:19 UTC (permalink / raw)
  To: jidanni; +Cc: bug-gnu-emacs, ding

jidanni@jidanni.org writes:
> And of course for we Geritol clubbers, what if one becomes deceased
> and one's chin hits SPC and nose hits RET. Do you want to be
> remembered by your community club as that guy who deleted all the
> files?

Somewhat off-topic: I once discussed the following on
bug-coreutils@gnu.org.

I have

  alias rm='rm --interactive'

But what I really would like was an interactive query that was
restricted to those cases when I have typed something on the command
line that doesn't tell me what rm will really do. Usually, this is
the case when the shell did some filename expansion. Unfortunately,
to the best of my knowledge it is not possible for a command like rm
to figure out whether the command shell performed some kind of
filename expansion or not.

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.

How is emacs' shell mode implemented? I use it more and more often
instead of a "plain terminal". Could it distinguish between these
cases?

Roland




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: shell-mode flakey
  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
                       ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Andreas Röhler @ 2007-12-18 19:51 UTC (permalink / raw)
  To: bug-gnu-emacs

Am Dienstag, 18. Dezember 2007 17:19 schrieb Roland Winkler:
> jidanni@jidanni.org writes:
> > And of course for we Geritol clubbers, what if one becomes deceased
> > and one's chin hits SPC and nose hits RET. Do you want to be
> > remembered by your community club as that guy who deleted all the
> > files?
>
> Somewhat off-topic: I once discussed the following on
> bug-coreutils@gnu.org.
>
> I have
>
>   alias rm='rm --interactive'
>
> But what I really would like was an interactive query that was
> restricted to those cases when I have typed something on the command
> line that doesn't tell me what rm will really do. Usually, this is
> the case when the shell did some filename expansion. Unfortunately,
> to the best of my knowledge it is not possible for a command like rm
> to figure out whether the command shell performed some kind of
> filename expansion or not.
>
> 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.
>
> How is emacs' shell mode implemented? I use it more and more often
> instead of a "plain terminal". Could it distinguish between these
> cases?
>
> Roland

Probably dired delivers what you are looking for.

Andreas Röhler




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: shell-mode flakey
  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
                       ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Miles Bader @ 2007-12-19  0:31 UTC (permalink / raw)
  To: Roland Winkler; +Cc: bug-gnu-emacs, ding, jidanni

Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
> 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.

One simple possibility might be a "--query-if-multiple" option, which
would act like -i if there was more than one command-line filename
argument.

That wouldn't  help for all cases, but I think it would catch a large
proportion of common typos...

-Miles

-- 
`There are more things in heaven and earth, Horatio,
 Than are dreamt of in your philosophy.'




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: shell-mode flakey
  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
  2007-12-19  2:22     ` Russ Allbery
       [not found]     ` <mailman.5185.1198024311.18990.bug-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 7+ messages in thread
From: Glenn Morris @ 2007-12-19  0:54 UTC (permalink / raw)
  To: Roland Winkler; +Cc: bug-gnu-emacs

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"'




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: shell-mode flakey
  2007-12-18 16:19   ` shell-mode flakey Roland Winkler
                       ` (2 preceding siblings ...)
  2007-12-19  0:54     ` Glenn Morris
@ 2007-12-19  2:22     ` Russ Allbery
       [not found]     ` <mailman.5185.1198024311.18990.bug-gnu-emacs@gnu.org>
  4 siblings, 0 replies; 7+ messages in thread
From: Russ Allbery @ 2007-12-19  2:22 UTC (permalink / raw)
  To: ding, bug-gnu-emacs

Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
>
> Somewhat off-topic: I once discussed the following on
> bug-coreutils@gnu.org.
>
> I have
>
>   alias rm='rm --interactive'
>
> But what I really would like was an interactive query that was
> restricted to those cases when I have typed something on the command
> line that doesn't tell me what rm will really do. Usually, this is
> the case when the shell did some filename expansion. Unfortunately,
> to the best of my knowledge it is not possible for a command like rm
> to figure out whether the command shell performed some kind of
> filename expansion or not.

Yeah, this is the reason why tcsh implements this in the shell rather than
in rm.  set rmstar in tcsh will cause tcsh to warn about the command rm
with an argument of * before it expands the wildcard, which is far more
useful than rm -i because it only prompts for an infrequent operation.  I
wish bash had that feature; it's one of the main things left that tcsh
will do that bash won't (so far as I know).

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: shell-mode flakey
       [not found]     ` <mailman.5185.1198024311.18990.bug-gnu-emacs@gnu.org>
@ 2007-12-19 16:25       ` Sven Joachim
  0 siblings, 0 replies; 7+ messages in thread
From: Sven Joachim @ 2007-12-19 16:25 UTC (permalink / raw)
  To: Miles Bader; +Cc: bug-gnu-emacs, jidanni, ding, Roland Winkler

On 2007-12-19 01:31 +0100, Miles Bader wrote:

> Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> writes:
>> 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.
>
> One simple possibility might be a "--query-if-multiple" option, which
> would act like -i if there was more than one command-line filename
> argument.
>
> That wouldn't  help for all cases, but I think it would catch a large
> proportion of common typos...

In coreutils 6.0 and higher, a similar option is implemented.  From the
NEWS file:

,----
|   rm now accepts the -I (--interactive=once) option.  This new option
|   prompts once if rm is invoked recursively or if more than three
|   files are being deleted, which is less intrusive than -i prompting
|   for every file, but provides almost the same level of protection
|   against mistakes.
`----

Cheers,
       Sven




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-12-19 16:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [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
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

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).