Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 559
user1934428 Avatar asked Jan 16 '15 16:01

user1934428


People also ask

What is rm command line?

Use the rm command to remove files you no longer need. The rm command removes the entries for a specified file, group of files, or certain select files from a list within a directory.

Which files would be deleted if you type rm a txt?

Does rm delete a file? The rm command does not delete a file. Instead it unlinks it meaning the data is still on disk but the link to it is removed.


1 Answers

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   ... } 
like image 167
hchbaw Avatar answered Sep 24 '22 06:09

hchbaw