| Author |
Message |
dfeustel@mindspring.com *nix forums addict
Joined: 13 May 2006
Posts: 67
|
Posted: Wed Jun 28, 2006 3:23 am Post subject:
Bug in ksh read command?
|
|
|
When the following construct is processed by ksh
running on OpenBSD 3.9 release (cd), a CR is left
appended to the end of $REPLY. That newline shows
up at the end of the last argument processed by
the C program mychk.
cat mesglog | while read
do
mychk $REPLY
done
Is this the expected behavior of ksh?
(My 1989 version of _The Kornshell says that the
newline is removed).
Thanks,
Dave Feustel
--
Using OpenBSD with or without X & KDE?
http://dfeustel.home.mindspring.com |
|
| Back to top |
|
 |
Peter Strömberg *nix forums beginner
Joined: 22 Feb 2005
Posts: 17
|
Posted: Wed Jun 28, 2006 6:52 am Post subject:
Re: Bug in ksh read command?
|
|
|
dfeustel@mindspring.com wrote in news:vCmog.6030$il.4542@trnddc03:
| Quote: | When the following construct is processed by ksh
running on OpenBSD 3.9 release (cd), a CR is left
appended to the end of $REPLY.
...
Is this the expected behavior of ksh?
(My 1989 version of _The Kornshell says that the
newline is removed).
|
CR (ascii 13) != newline (ascii 10)
"Only" space, tab and newline are in $IFS
That the tty line disipline usually converts CR input from keyboard to NL
(stty icrnl) doesn't matter for files |
|
| Back to top |
|
 |
dfeustel@mindspring.com *nix forums addict
Joined: 13 May 2006
Posts: 67
|
Posted: Wed Jun 28, 2006 12:18 pm Post subject:
Re: Bug in ksh read command?
|
|
|
"Peter Str?mberg" <wilfried@spamcop.net> wrote:
| Quote: | dfeustel@mindspring.com wrote in news:vCmog.6030$il.4542@trnddc03:
When the following construct is processed by ksh
running on OpenBSD 3.9 release (cd), a CR is left
appended to the end of $REPLY.
...
Is this the expected behavior of ksh?
(My 1989 version of _The Kornshell says that the
newline is removed).
CR (ascii 13) != newline (ascii 10)
"Only" space, tab and newline are in $IFS
That the tty line disipline usually converts CR input from keyboard to NL
(stty icrnl) doesn't matter for files
|
What happens when the arguments are written to the console is that any
output following the argument with the appended CR is printed starting
at column 1, overwriting the data previously written to the line.
Definitely not the output appearance that I was expecting.
--
Using OpenBSD with or without X & KDE?
http://dfeustel.home.mindspring.com |
|
| Back to top |
|
 |
dfeustel@mindspring.com *nix forums addict
Joined: 13 May 2006
Posts: 67
|
Posted: Wed Jun 28, 2006 6:10 pm Post subject:
Re: Bug in ksh read command?
|
|
|
dfeustel@mindspring.com wrote:
| Quote: | "Peter Str?mberg" <wilfried@spamcop.net> wrote:
dfeustel@mindspring.com wrote in news:vCmog.6030$il.4542@trnddc03:
When the following construct is processed by ksh
running on OpenBSD 3.9 release (cd), a CR is left
appended to the end of $REPLY.
...
Is this the expected behavior of ksh?
(My 1989 version of _The Kornshell says that the
newline is removed).
CR (ascii 13) != newline (ascii 10)
"Only" space, tab and newline are in $IFS
That the tty line disipline usually converts CR input from keyboard to NL
(stty icrnl) doesn't matter for files
What happens when the arguments are written to the console is that any
output following the argument with the appended CR is printed starting
at column 1, overwriting the data previously written to the line.
Definitely not the output appearance that I was expecting.
|
It looks like the simplest way to deal with this problem is to insert
a tr "\r" "\n" command in an appropriate place in any data pipe where
the \r character is a problem.
--
Using OpenBSD with or without X & KDE?
http://dfeustel.home.mindspring.com |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|