Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: set -F kills read -t



On 03/18/2014 10:30 PM, Jan Larres wrote:
The best way to do that, and presumably the way grep itself does it, is
to test whether stdin is connected to a terminal:

mygrep() {
     if [ -t 0 ]; then
         echo terminal
     else
         read input
         echo $input input
     fi
}

$ mygrep
terminal
$ echo foo | mygrep
foo input

Bloody marvellous! That scratches my itch just perfectly, thanks Jan.

I wish there was some web site: "101 things you still don't know you can do with
zsh, and why you want to know them".



Messages sorted by: Reverse Date, Date, Thread, Author