Why rm -f asks me for confirmation on zsh?

I am running zsh from Cygwin. One of my shell functions contains an operator

rm -f somedir/* 

(I want to delete all non-hidden files in somedir, but not the directory itself). However, they always ask me:

 zsh: sure you want to delete all the files in ... [yn]? 

The wording of this post (note the "zsh:" at the beginning) suggests that the question comes from zsh, not rm. However, rm is an external command:

 $ type rm rm is /usr/bin/rm 

By the way, a hint also occurs if I explicitly call rm as

 $ command rm -f somedir/* 

Is there something inside zsh that is trying to be too smart?

+5
source share
1 answer

It seems that RM_STAR_SILENT is NOT valid.
You can do setopt rmstarsilent to tell zsh to not confirm rm * .

Shell option RM_STAR_SILENT :

Do not prompt the user before running rm * or rm path/* .

- zshoptions(1): RM_STAR_SILENT


If you want to make the setopt effect temporarily only in this shell function, you can use it in combination with localoptions as shown below:

 my-test () { setopt localoptions rmstarsilent ... } 
+11
source

Source: https://habr.com/ru/post/1211271/


All Articles