Artificial intelligent assistant

read command in zsh throws error In zsh, running the command `read -p 'erasing all directories (y/n) ?' ans`, throws the error, read: -p: no coprocess But in bash, it prints a prompt. How do I do this in zsh?

You can still use `read`, you just need to print a prompt first. In `zsh`, `-p` indicates that input should be read from a coprocess instead of indicating the prompt to use.

You can do the following instead, which is POSIX-compliant:


printf >&2 '%s ' 'erase all directories? (y/n)'
read ans


Like for ksh/zsh's `read 'var?prompt'` or bash's `read -p prompt var`, the prompt is issued on stderr so as not to pollute the normal output of your script.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 83d173d3ad09d5d3f1fd12f248a3fc71