Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: noglob does not call alias?




13.03.14, 13:01, "Amm" <ammdispose-zsh@xxxxxxxxx>":
> 
> Hello,
> 
> So I was just trying this.
> 
> $ alias rm='nocorrect rm -i'
> $ touch 1 2
> 
> $ ls
> 1  2
> 
> 
> $ rm 1
> rm: remove regular empty file `1'? n
> 
> $ noglob rm 1
> 
> $ ls
> 2
> 
> 
> Shock!! File deleted without asking for confirmation?!
> 
> I think this is not what (new zsh) user expects.
> 
> How do I prevent this?
> 
> 
> Also 'noglob' does not respect RM_STAR_SILENT=off.
> 
> $ unsetopt RM_STAR_SILENT
> $ rm *
> 
> zsh: sure you want to delete all the files in ... [yn]? n
> rm: missing operand
> Try `rm --help' for more information.
> 
> First I think when I said 'n'(no), it should not call
> 'rm' at all instead of calling it without any filename.
> 
> But, anyway, continuing with my e-mail:
> 
> 
> $ noglob rm *
> rm: cannot remove `*': No such file or directory
> 
>     
> 
> This caused no harm here but I would still prefer that
> it should ask if I am sure to delete all the files.
> (Purpose here is to warn user of scary error!)

I am not sure I understand correctly: do you say that "noglob rm *" should ask whether user wants to delete all files? It is not correct: due to the definition of "noglob" "noglob rm *" is "rm '*'": you ask do delete file named star, not to remove all files. Coreutils commands do not expand their arguments as it the job of the shell which in turn was told not to do this as well (noglob). Unless you use cygwin AFAIR.

> 
> 
> 
> So any idea?
> 
> Thanks in advance,
> 
> 
> Amm



Messages sorted by: Reverse Date, Date, Thread, Author