Le 16/06/2010 19:03, Greg Wooledge a écrit :
> On Wed, Jun 16, 2010 at 07:47:03PM +0200, Krzysztof ??elechowski wrote:
>> The description of the read builtin [19] would benefit of the following note:
>> Warning: A pipeline of the form { echo 1 2 | read a b; } is not useful. Use
>> {
>> read<<<"1 2" a b; } instead.
> That kind of advice is certainly welcome in tutorials, guides, and so on
> which are teaching shell programming. I don't really think it needs to
> go into the manual, though. There are hundreds, if not thousands, of
> things you should _not_ do, that shouldn't have to be stated in the
> reference manual. This is just one of them.
- I do not think this is "just one of them". This question
pops up VERY regularly here, many times more than other
things that should not be done.
- Consider the very first sentence in the documentation:
<http://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html#index-read-142>
read
One line is read from the standard input, or from...
Such a description obviously begs for a pipeline; no surprise everyone
makes this mistake one day or the other.
- The POSIX standard does allow "echo 1 2 | read a b" to be useful
(cf. 2.12 "Shell Execution Environment"). Some alternatives to
bash actually make it useful. Standard and portability concerns
definitely belong to a reference manual.