[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no trailing newline causes read to fail
From: |
Stephane Chazelas |
Subject: |
Re: no trailing newline causes read to fail |
Date: |
Mon, 4 Oct 2004 15:32:32 +0100 |
User-agent: |
Mutt/1.5.6i |
On Mon, Oct 04, 2004 at 09:50:34AM -0400, Paul Jarc wrote:
[...]
> > No, E4 is about read being run in a subshell. OP's problem is
> > for read on non-text input (an unterminated line causes read to
> > exit with a non-zero exit status).
>
> No. "read" still sets the variable even in this case, so it does not
> explain the complaint above about the variable being empty. That is
> explained by FAQ entry E4.
[...]
All right, OK, sorry, I missed that part of the OP's post. The
example he gave actually didn't involve a sub-process. He must
have ommited the important thing, he probably used
paste /tmp/f | while read line; do ...; done
instead of:
while read line; do ...; done < /tmp/f
[OT:
It's true that most shells set the variable when the input line
is not terminated. But with some versions of ksh, it is
truncated:
$ printf foo | /usr/dt/bin/dtksh -c 'read line; echo "$? $line"'
1 fo
(dtksh on Solaris 8 is ksh93d)
]
--
Stephane
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________