Subject: Re: bin/2698: sh is fragile
To: None <current-users@NetBSD.ORG>
From: Peter Seebach <seebs@solon.com>
List: current-users
Date: 08/15/1996 08:37:47
>> >Number: 2698
>> >Category: bin
>> >Synopsis: sh chokes on \r's.
>> ...
>> >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.
>Hmm, since '\r' most often appears at the end of lines, treating
>it as either tab or space would have negative effects if the last
>real character seen was a backslash used to indicate a
>continuation of the command on the next line, no?
Oh, that's bad.
Huh.
I begin to think there's no good solution. I intuitively object to treating
any character for which isspace() is non-zero as anything but space.
BTW, I see several places in which sh's code appears to refer to \t and ' ' as
such; shouldn't that be something like $IFS?
Perhaps what Unix needs is "text mode", in which \r's are silently ignored on
input. (Obviously, they would not be generated on output.)
-s