bug-bash
[Top][All Lists]
Advanced

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

Re: A note for read builtin


From: Marc Herbert
Subject: Re: A note for read builtin
Date: Thu, 17 Jun 2010 09:28:48 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-2.fc12 Thunderbird/3.0.4

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.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]