[TUHS] On computerese

Dan Cross crossd at gmail.com
Tue Sep 17 06:55:08 AEST 2024


On Mon, Sep 16, 2024 at 7:31 AM Edouard Klein <edouardklein at gmail.com> wrote:
> George Michaelson <ggm at algebras.org> writes:
> > cat is capable of endless discussion.
> >
> > cat thing | cat otherthing doesn't do what (some) people think.
> > cat thing | cat otherthing /dev/stdin does, but there's an ordering
> > point to be made.
> > cat thing | cat < otherthing /dev/stdin makes the ordering point. and
> > the number of lines seen.
>
> I'm not sure of the point you are making with your last example, which
> gave me pause. I had to run it to see what it does.
>
> I correctly guessed that only one of thing or otherthing would be printed,
> but I was not able to guess if the | or the < would take precedence.
>
> Is there a simple reason why the < has priority over | for the stdin ?

I suppose this depends entirely on the shell; perhaps that is the
point. Arguably, being the target of a pipe _and_ having a redirect on
stdin should be some kind of an error, but regardless, something that
is true is that is that the second `cat` command will only see
whatever is on `stdin` as it reads from `/dev/stdin`, but what is _on_
stdin can be confusing.

        - Dan C.


> If the < precedence was your point, why did you specify /dev/stdin ?
> cat thing | cat < otherthing
> makes the point.
>
> Is there a finer point I am missing ?
>
> Sorry for being dense. I'm happy, after more that 20 years of Unixing,
> to see something new even with such supposedly basic commands. Thank you
> for your brain twister.


More information about the TUHS mailing list