Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Bash / Shell Scripting (http://www.programmingforums.org/forum26.html)
-   -   reading stdin (http://www.programmingforums.org/showthread.php?t=12143)

a thing Dec 9th, 2006 4:12 AM

reading stdin
 
I want to read stdin and put it in array foo, but I don't want to bring up the prompt if stdin is empty, like
:

read -a foo
does. If "-t 0" is passed to read, then it doesn't put stdin into $foo when there's actually something in stdin.

a thing Dec 9th, 2006 9:16 PM

I found a way:
:

if ! [ -t 0 ]; then
        read -a foo
fi


Finished script (until I find another thing I should but haven't implemented): http://athingis.boldlygoingnowhere.org/software/prefix


All times are GMT -5. The time now is 11:14 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC