Avoid asterisk expansion when it selects "everything"

2016-04-13 Thread Anis ELLEUCH
Hello everybody,

I would like to ask if it is possible to disable expanding asterisk when it
selects all entries ?

`$ rm * .jpg` with a mistaken space between asterisk and .jpg will delete
everything in your home directory or in the entire disk.

In my opinion, when the user asks to select "everything" which could be `*`
or `path/*`, bash has to show a confirmation prompt to check if the user
was not mistaken, this option should be obviously disabled by default

Another idea: `*` and `/*` should not be interpreted and the user has to
enter another sequence "more powerful" to emphasize selecting all entries (
`^*` would it work just fine ?)

Cordially,
-- 

Sent from my mobile


Re: Avoid asterisk expansion when it selects "everything"

2016-04-25 Thread Anis ELLEUCH
Thanks for all your responses.

I think that bash as a programming language is also an everyday tool. The
idea of a strong character that selects all files, is it bad?

Le jeu. 14 avr. 2016 à 09:07, Stephane Chazelas 
a écrit :

> 2016-04-13 11:23:01 +0000, Anis ELLEUCH:
> > Hello everybody,
> >
> > I would like to ask if it is possible to disable expanding asterisk when
> it
> > selects all entries ?
> >
> > `$ rm * .jpg` with a mistaken space between asterisk and .jpg will delete
> > everything in your home directory or in the entire disk.
> >
> > In my opinion, when the user asks to select "everything" which could be
> `*`
> > or `path/*`, bash has to show a confirmation prompt to check if the user
> > was not mistaken, this option should be obviously disabled by default
> >
> > Another idea: `*` and `/*` should not be interpreted and the user has to
> > enter another sequence "more powerful" to emphasize selecting all
> entries (
> > `^*` would it work just fine ?)
> [...]
>
> zsh does that by default:
>
> $ rm * .jpg
> zsh: sure you want to delete all the files in /tmp [yn]?
>
> (disabled with "setopt RM_STAR_SILENT")
>
> Also in tcsh, though not enabled by default there:
>
> > set rmstar
> > rm *
> Do you really want to delete all files? [n/y]
>
> (they match on "rm *" or "rm dir/*")
>
> For bash, you can try this approach:
>
> https://unix.stackexchange.com/questions/108803/preventing-deletion-of-system-shell-aliased-folders/108854#108854
>
> --
> Stephane
>
-- 

Sent from my mobile