Shell script - is this expected behaviour?

Gary listgj-cygwin@yahoo.co.uk
Tue Nov 29 10:04:00 GMT 2011


If I have a shell script which reads a file which does not have an end
of line character at the end if it's only line, it does not read
anything.

For example:
,----
| #!/bin/sh
| 
| fileName="test.xml"
| retVal="Z"
| 
| exec 10<&0
| exec < $fileName
| while read configLine
| do
|     retVal="A"
| done
| exec 0<&10 10<&-
| 
| echo $retVal
| 
| exit 0
`----

If it's expected behaviour, what's the workaround?

-- 
Gary        Please do NOT send me 'courtesy' replies off-list.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list