If you don't feed anything to the script, it will sit there waiting for you to enter something. When you do, it will be put into $text
and then the script will continue to wait for you to enter something. When you do, that will go into $text1
. Subsequently, the script will once again wait for you to enter something. Once that is done, the input will go into $text2
. Then, the whole thing will repeat indefinitely.
If you invoke the script as
$ script < input
where input
is a file, the script will read lines from the file similar to above, then, when the stream runs out, will start assigning undef
to each variable for an infinite period of time.
AFAIK, there is no programming language where reading from the predefined STDIN
(or stdin
) file handle requires you to invoke your program as:
$ script < /dev/stdin