[net.bugs] "read" bug in sh

tim@dciem.UUCP (Tim Pointing) (05/09/84)

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