[R] use of "input" in system()

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Thu Apr 30 20:59:58 CEST 2009


Mike Miller wrote:
> On Fri, 24 Apr 2009, Duncan Murdoch wrote:
>
>> On 4/24/2009 10:29 AM, Mike Miller wrote:
>>
>>> First, it looks like there is bug in the documentation...
>>>
>>> According to the documentation for system():
>>>
>>> http://stat.ethz.ch/R-manual/R-patched/library/base/html/system.html
>>>
>>>    input  if a character vector is supplied, this is copied one
>>> string per
>>>           line to a temporary file, and the standard input of
>>> command is
>>>           redirected to the file
>>>
>>> This seems to mean that the standard input of command is redirected
>>> *from* the file.  From the file, to the command.  Example:
>>
>> The redirection is done *to* the file handle.  The fact that input is
>> read from that handle is a different issue.
>
>
> Thanks very much for the reply.  After seeing your response, I'm sure
> the document isn't wrong (not a bug) but it is a very terse
> explanation that I think many people will find hard to follow, as I did.

it doesn't seem to be the usual way of explaining the matters.  the bash
reference manual [1, sec. 3.6.1] (see also man bash) says:

"
Redirection of input causes the file whose name results from the
expansion of word to be opened for reading on file descriptor |n|, or
the standard input (file descriptor 0) if |n| is not specified.

The general format for redirecting input is:

     [n]<word

"

it definitely not saying 'redirection to'.  even more contrary to what
duncan says is man page of the sh shell (man sh):

"
[n]< file   Redirect standard input (or n) from file.
"

note the *from*.

in peters' expert shell scripting [1, ch. 9, p. 60] it is stated:

"
expression < file: Redirect the contents of file into the expression.
"

while r's "standard input of command is redirected to the file" can
certainly be read correctly once one knows what it really means, it is
an unfortunate and misleading expression, and it might be a good idea to
fix it. 

yet another example of how creative documentation is not necessarily
good documentation.

vQ




More information about the R-help mailing list