🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.mail.mush
Article #300

Re: Bug with pipe command

#300
From: Barton E. Schaefer
Date: Fri, 08 Dec 1989 19:12
48 lines
2762 bytes
In article <128954@sun.Eng.Sun.COM> jss@sun.com (Josh Sirota) writes:
} There seems to be a bug in 7.0.0.0.  I can do "|3 cat" but I can't do
} "| 3 cat", which is inconsistent with both other mush commands and with
} UCB mail.  The second form ignores the "3" and just uses the current
} message.

Actually, you're using the wrong syntax in both cases (and if either of
those syntaxes is correct in UCB mail, well, then this is one of those
places where mush isn't the same and never will be).  However, I'm
surprised that you get any different behavior from the two -- I get
exactly the same thing from both; the tokenizer separates the `|' from
the `3' almost immediately -- you can watch the fun with "debug 4".
If you can put together a script of debugging output showing your odd
behavior, please send it to me.

When you type "| 3 cat", you are piping the current message to the
command "3" with argument "cat".  The command "3" is an internal
shorthand for "print 3", so the effect is the same as "print . 3 cat"
(print the current message and message 3; the "cat" is ignored,
because "print" takes only message numbers/metachars as arguments).

The reason it works this way is because `|' is a command separator,
not a command, just as in the "real" shells.  Mush special-cases a `|'
with no left-hand side to mean "feed the current message to the pipe".
UCB mail has no separators (except newline), so if it works as Josh
describes, that's because it is interpreting `|' as a command name.

What you should be typing is

	3 | cat

However, if you want "| 3 cat" to work, you can employ "cmd" to force
mush to interpret `|' as a command name:

    cmd '|' pipe

This can make for some really interesting syntax, because the parser is
actually rather clever about figuring out when to use `|' as a separator
and when not to ....

By the way, for you mush novices reading this, most of what is described
above depends on having the variable $unix set; it will all work slightly
differently otherwise.
-- 
Bart Schaefer     "I seem to have run into a novel problem with the electronic
                       mail.  My computer's demanding an electronic female."
schaefer@cse.ogi.edu
(used to be cse.ogc.edu)                              "Preferably brunette."
Technical Details
Message-ID: <6049@ogicse.ogc.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ogicse!schaefer
References: <128954@sun.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ogicse!schaefer
From: schaefer@ogicse.ogc.edu (Barton E. Schaefer)
Newsgroups: comp.mail.mush
Subject: Re: Bug with pipe command
Message-ID: <6049@ogicse.ogc.edu>
Date: 8 Dec 89 19:12:17 GMT
References: <128954@sun.Eng.Sun.COM>
Reply-To: schaefer@ogicse.UUCP (Barton E. Schaefer)
Organization: Oregon Graduate Institute (formerly OGC), Beaverton, OR
Lines: 48