niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » *nix » BSD » OpenBSD
Bug in ksh read command?
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
dfeustel@mindspring.com
*nix forums addict


Joined: 13 May 2006
Posts: 67

PostPosted: Wed Jun 28, 2006 3:23 am    Post subject: Bug in ksh read command? Reply with 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. 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

PostPosted: Wed Jun 28, 2006 6:52 am    Post subject: Re: Bug in ksh read command? Reply with quote

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

PostPosted: Wed Jun 28, 2006 12:18 pm    Post subject: Re: Bug in ksh read command? Reply with quote

"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

PostPosted: Wed Jun 28, 2006 6:10 pm    Post subject: Re: Bug in ksh read command? Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Tue Dec 02, 2008 2:34 pm | All times are GMT
navigation Forum index » *nix » BSD » OpenBSD
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Solaris dd command problem prak Solaris 0 Fri Jul 21, 2006 5:43 am
No new posts Solaris dd command problem prak Solaris 0 Fri Jul 21, 2006 5:43 am
No new posts Solaris dd command problem prak Solaris 4 Fri Jul 21, 2006 5:43 am
No new posts ConfigParser: what read('non-existent-filename') returns ... Danil Dotsenko python 4 Thu Jul 20, 2006 5:50 pm
No new posts socket read modifies third parameter after the call: Very... jainarunk@gmail.com networking 1 Thu Jul 20, 2006 3:47 pm

Mobile Phone | Consolidate Student Loans | Equity Release | Free Ringtones | Myspace Layouts
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1613s ][ Queries: 16 (0.0846s) ][ GZIP on - Debug on ]