Bug in /etc/cron.d/mlocate.cron or am I crazy?
Michael Schwendt
mschwendt at gmail.com
Sun Nov 29 09:27:01 UTC 2009
On Sat, 28 Nov 2009 14:51:58 -0500, Steven wrote:
> I am very interested in this question on multiple levels.
>
> Let's start at the first level:
>
> foo=$(< fn bar)
>
> apparently is functionally equivalent to
>
> foo=$( bar < fn )
True. File fn is opened for input on file descriptor 0 (stdin) in
both examples.
> which really is quite different from
>
> foo=$(cat fn | bar)
True. This is something different due to introducing a pipeline, which
does something else than redirecting input.
> which actually runs at least two child processes.
True.
> I do *not* see anything in the bash man page, either in the description for
> $(< ) which says that it is functionally equivalent to using cat,
"cat file | command" connects standard output to standard input by using a
pipeline. That's equivalent to "command 0< file" which redirects the
contents of a file to standard input, file descriptor 0. The 0 can be
omitted as it is the default.
cat /proc/filesystems
cat /proc/filesystems | cat
cat < /proc/filesystems
< /proc/filesystems cat
all yield the same output and hence can be executed as name=$(...) or
name=`...` to assign the output to a variable.
> but does not
> explain anything about pipes being illegal in this context.
Not illegal, but plain wrong. A pipe is connected to output, the
"<file" gives you input. Where you inserted the pipe, you don't have
any output (on stdout). It was like
0< /proc/loadavg | cat
which opens /proc/loadavg for reading (giving you input on stdin, fd 0)
and '|' waiting for output on stdout. The input from /proc/loadavg is
lost, since nothing reads it. The pipe doesn't see any output from
anything, hence its input to "cat" is the same. Final output is empty.
> I also do not see
> anything of relevance to this topic in the bash man page on REDIRECTION.
First chapter, as I said:
| The following redirection operators may precede or appear
| anywhere within a simple command or may follow a command. Redirections
| are processed in the order they appear, from left to right.
> At
> best, the man page is deficient in that it *should* say that the syntax
> defaults to qq=$(0< filename) and that other values besides zero are supported.
>
See further below in section "Redirecting Input" where it explains
the general syntax "[n]<word".
More information about the fedora-list
mailing list