'Why does rm -f ask me for confirmation on zsh?

I'm running zsh from Cygwin. One of my shell functions contains a statement

rm -f somedir/*

(I want to remove all non-hidden files in somedir, but not the directory itself). However, I am always asked:

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

The wording of this message (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, the prompt also occurs if I explicitly invoke rm as

$ command rm -f somedir/*

Is there something within zsh, which tries to be too clever?

zsh


Solution 1:[1]

It seems that the RM_STAR_SILENT is NOT in effect.
You could do setopt rmstarsilent either in the command line or in ~/.zshrc to tell zsh to not confirm a rm *.

The shell option RM_STAR_SILENT is:

Do not query the user before executing rm * or rm path/*.

-- zshoptions(1): RM_STAR_SILENT


If you want to make the setopt effect temporally just in that shell function only, you could use it in conjunction with the localoptions like below:

my-test () {
  setopt localoptions rmstarsilent
  ...
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Les Nightingill