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".