[comp.mail.mush] Bug with pipe command

jss%greeble@Sun.COM (Josh Sirota) (12/08/89)

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.

Josh
--
Josh Sirota
Sun Microsystems, NSE group
INTERNET: jss@sun.com			UUCP: ...!sun!jss

schaefer@ogicse.ogc.edu (Barton E. Schaefer) (12/09/89)

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