read -p "Enter your name: " NAME
echo "Hello $NAME, nice to meet you".```
In terminal:
ks@USER Desktop % ./script.sh ./script.sh:read:18: -p: no coprocess Hello , nice to meet you.
[picture of the problem ][1]
[1]: https://i.sstatic.net/ZpVri.png
In ZSH -p
doesn't mean prompt as in Bash. See man zshbuiltins
:
read [ -rszpqAclneE ] [ -t [ num ] ] [ -k [ num ] ] [ -d delim ]
(...)
-p Input is read from the coprocess.
To get a prompt with ZSH implementation of read
:
$ read "?Enter your name: " NAME
Enter your name: myname
$ echo $NAME
myname