cc: [email protected]
Subject: Re: [ast-developers] read ignores an input line missing a trailing
newline
--------
> Living in a mixed unix/linux/windows world, this has bitten me more than
> once:
>
> $ /usr/bin/perl -e ' print "a b\nc d" ' | while read x y ;do echo
> "<$x><$y>" ;done
> a b
>
> I can't see how it is not a bug to silently discard/ignore the non-empty
> data after the last newline in a file.
>
> Since this bug appears to have been present in ksh and bash since the
> time of Moses, so maybe it's too late to change the behavior. However,
> I haven't found it documented anywhere; could this behavior at least be
> documented?
Since read has encountered an EOF, it must return an exit status > 1.
However, ksh does process the last partial line.
print -n $'a b\nc d' | while read x y ;do echo "<$x><$y>" ;done
echo "<$x><$y>"
Will output
a b
c d
David Korn
[email protected]
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers