🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs
Article #203

"read" bug in sh (v7 and 4.2)

#203
From: Tim Pointing
Date: Wed, 09 May 1984 14:14
31 lines
1645 bytes
There is an inconsistancy between the documentation for the "read" command
and its actual functioning. The documentation states "succesive words of
the input are assigned to the variables name ...". If the input to a "read"
command has multiple-blanks in a row (e.g. the output from "date" before
the 10'th of the month), then variables corresponding to the second and
following blanks are set to null. I.e. "read" is taking blanks (actually
any IFS character) to mean "that's the end of another word, on to the next";
when multiple blanks are input, corresponding variable get set to null.
Since "words" are supposed to be blank-delimited strings, multiple blanks
should be compressed to single blanks.
The bug is in the "readvar" routine in name.c (one of the least cryptic
source files) but I don't have the time available to try to fix it.

Example:
$ read a b c
this  is text
$ echo $a
this
$ echo $b

$ echo $c
is text


Should this bug be fixed, or have some people used this misfeature in
shell programs?

-- 
	Tim Pointing, DCIEM
	{allegra,ubc-vision,linus,ihnp4,uw-beaver,floyd}!utcsrgv!dciem!tim
or	{allegra,ihnp4,linus,decvax}!utzoo!dciem!tim
Technical Details
Message-ID: <913@dciem.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!dciem!tim

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site dciem.UUCP
Path: arc1-ca.pugleaf.net!utzoo!dciem!tim
From: tim@dciem.UUCP (Tim Pointing)
Newsgroups: net.bugs
Subject: "read" bug in sh (v7 and 4.2)
Message-ID: <913@dciem.UUCP>
Date: Wed, 9-May-84 10:14:41 EDT
Article-I.D.: dciem.913
Posted: Wed May  9 10:14:41 1984
Date-Received: Wed, 9-May-84 12:27:51 EDT
Organization: D.C.I.E.M., Toronto, Canada
Lines: 31