Re: Bug in /etc/cron.d/mlocate.cron or am I crazy?

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

 



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".

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux