Hello, I have a script that asks to create a target dir if it doesn't exist.
to that extend I inserted an
read -k1
in the script.
To be able to ask the user for confirm even when the script stdin is connected to a pipe I did
read -k1 < /dev/tty
I now would like to be able to deactivate this behavior when the process has no controlling terminal, eg when run from cron. To simulate this I tried:
setsid zsh -c 'read -k1 < /dev/tty'
which gives:
zsh:1: no such device or address: /dev/tty
how can I prevent this error, so that I don't invoke read when there is no controlling terminal for the current process?
thanks