[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Read?



for now, there is no read-like builtin in es.  people have proposed
adding it or line, which seems perfectly reasonable.  whenever this
discussion starts, it seems to get bogged down in ``system x does it
this way'' but ``system y does it this way'' and ``in an ideal world
it would be done this way'' sorts of messages.

so, i'm going to proposed something that is not the same as other
systems, but should work.  please complain about things that can't
be done with this functionality, not that it's not like other systems.

the %read builtin returns either the empty list (in the case of end-of-file)
or a single element string with up to one line of data read from standard
input (including possible redirections).  %read will read one character
at a time in order to not read more data out of a pipe than it should.
the terminating newline (if present) is not included in the returned
string.

i believe that /bin/sh-style read and the well-known line function can
be implemented based on this builtin.

please comment on the proposed semantics.  possible variations:

	+ don't strip the trailing newline
	+ let %read take a prompt argument, ala %parse
	+ use readline/editline if appropriate
	+ don't hardcode the line delimiter as \n
	+ not including any such builtin and dropping the idea entirely

paul