community. I recently started to use zsh instead of bash and now i'm getting some problems that cannot be found on bash.
One of theme: when i use read -p command, obviously with flag -p, i get an error that says:
read: -p: no coprocess
On the other hand when I switch to bash again, this command works perfectly.
My full command:
read -p "what's your name" nameThank you for help <3
1 Answer
The usage is not compatible between shells.
As explained in man zshbuiltins, the way to emit a prompt string for a zsh read command is to append it to the identifier name after a ?:
If the first argument contains a `?', the remainder of this word is used as a prompt on standard error when the shell is interac‐ tive.
So for example
% read name\?"what's your name? "
what's your name? (the ? needs to be escaped here to prevent the shell treating it as a globbing character) or
% read "name?what's your name? "
what's your name? See also: