How can I prompt for yes/no style confirmation in a zsh script?

From zsh – read

If the first argument contains a ‘?’, the remainder of this word is used as a prompt on standard error when the shell is interactive.

You must quote the entire argument

read -q "REPLY?This is the question I want to ask?"

this will prompt you with This is the question I want to ask? and return the character pressed in REPLY.

If you don’t quote the question mark, zsh tries to match the argument as a filename. And if it doesn’t find any matching filename, it complains with no matches found.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)