Incomplete logout panel
Les Mikesell
lesmikesell at gmail.com
Mon Aug 29 04:32:43 UTC 2005
On Sun, 2005-08-28 at 22:43, Jeff Vian wrote:
> > > > > > cat > /etc/sysconfig/desktop << EOF
> > > > > > DESKTOP="KDE"
> > > > > > DISPLAYMANAGER="KDE"
> > > > > > EOF
> > > >
> > > > Cat copies input to output ................
> > > Thanks for your explanation. I had taken Tony's suggestion and started looking
> > > at the man bash pages. So, if I'm getting it right, the above sequence says
> > > take what I'm about to type and redirect the text into the file 'desktop' in
> > > the designated location, and keep doing that until I type "EOF" - the first
> > > '>' is the redirect, and the '<<' is the entry that tells the process to
> > > continue until it sees the sequence that immediately follows '<<', at which
> > > point the redirect process terminates. Do I have that right?
> >
> > Yes, but note that it is the shell collecting the input when
> > you use this construction, then feeding it to cat. If you
> > just:
> > cat >file
> > type...type
> > type..
> > control-d
> > cat inherits your keybord as it's stdin, and a special case
> > for tty type inputs is that control-d as the first thing
> > after a newline generates an end-of-file as seen by the
> > reading program (controlled by "stty").
> >
>
> This is true, but the control-d is the universal eof input for many
> apps. This is the true eof character and makes things operate as if
> they actually read an eof (as they would if input were from a file and
> processing continued to the end of file).
Close, but not quite. Apps never see a control-d and know
nothing about its use as the eof character from the keyboard.
Programs doing an unbuffered read() see 0 characters returned;
programs using getc() receive the out-of-band EOF value. It
is the tty subsystem that converts the control-d input after
a newline to an eof condition when running in "cooked" mode.
> The most common usage of cat
> in fact is to display the contents of a file and that terminates when
> the eof is reached/read, thus the 'cat' process terminates when given a
> control-d whether from stdin or from a file.
Or a pipe, which also generates an eof condition to the reader
when the writing side is closed and the contents have been
consumed.
> In the example above with the line
> cat > /etc/sysconfig/desktop << EOF
> it is telling the shell to allow cat to continue processing until it
> reads a literal string with the three characters "EOF". In this usage
> format, when the "EOF" is seen the shell sends a literal eof character
> (control-d) to the cat process (cat never actually sees the string EOF).
>
> While the functionality is similar the means is totally different.
In the last case, the shell starts cat with stdin connected to
a pipe, send the data up to the text EOF in the shell input into
the pipe, then closes the writing side of the pipe.
--
Les Mikesell
lesmikesell at gmail.com
More information about the fedora-list
mailing list