shell - How pipe to zsh read? -
with bash fine:
$ yes | bash -c 'read -sn 1 -p "[y/n] " response ; echo $response' y but zsh have trouble:
$ yes | zsh -c 'read -sk 1 "response?[y/n] " ; echo $response' [y/n]
when -k option used, zsh's read command read terminal unless instructed otherwise. documented in appropriate section of zshbuiltins manpage. pipe supplying standard input script, has no effect on attempts read terminal.
you can add -u 0 call read tell read standard input (file descriptor 0) when other options (such -k) cause read elsewhere.
Comments
Post a Comment