fun()
{
while read x
do
echo $x
done < somefile_that_does_not_exists
}
fun
echo I am here
Korn shell on HPUX prints the message "I am here", while the behaviour is different on AIX korn shell. We do not get the message on AIX. Any clues on how to get a similar behaviour.
Yes, well I have it running on HP-UX with a file not found error then the "I am here" bit, but on AIX 6.1, AIX 5.1 (please don't laugh yet) and ...... AIX 4.3.3 :o I just get the file not found error and the script aborts.
I also inserted
#!/bin/ksh
as the first line to be sure, but no change. I presume that this is suddenly a good reason to use cat!!!
If I write this in my natural style as
#!/bin/ksh
fun()
{
cat some_file_that_does_not_exist | while read x
do
echo $x
done
}
fun
echo I am here
...it works fine on AIX too.
Can anyone explain the mismatch?
.... and here's me battling my instincts to avoid a useless use of cat such as cat $file | while code. :rolleyes: