Subject: bin/2698: sh is fragile
To: None <gnats-bugs@NetBSD.ORG>
From: Peter Seebach <seebs@taniemarie.solon.com>
List: netbsd-bugs
Date: 08/14/1996 13:47:37
>Number:         2698
>Category:       bin
>Synopsis:       sh chokes on \r's.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 14 17:35:02 1996
>Last-Modified:
>Originator:     Peter Seebach
>Organization:
Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
Unsolicited email is not welcome, and will be billed for at consulting rates.
The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
>Release:        1.2_BETA
>Environment:
System: NetBSD taniemarie 1.2_BETA NetBSD 1.2_BETA (SEEBS) #3: Wed Jul 24 00:10:48 CDT 1996 seebs@taniemarie:/usr/src/sys/arch/amiga/compile/SEEBS amiga


>Description:
	Even the most trivial shell script produces syntax errors if there
	are ^M's at the ends of lines.  Since ^M is whitespace, this is a
	bug.  It looks like the source frequently checks for ' ' or '\t'.
	It should probably check for isspace(c) && c != '\n'.

>How-To-Repeat:
	Append 
's to any simple script, watch sh die.
>Fix:
	From looking at the source, fix sh so that it uses a function for all
	of those "is this space" commands, and then make '\r' either act
	like '\n' or like '\t' - it should definitely be space, and I don't
	care much whether it's a line break or a space at the end of a line.
	I would probably make it like \t or ' ', so it would be less
	intrusive on scripts.
>Audit-Trail:
>Unformatted: