9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: quanstro@speakeasy.net
To: 9fans@cse.psu.edu
Subject: [9fans] Re: 9base ports to unix (flame of byron's rc)
Date: Sat, 20 Aug 2005 15:25:41 +0000	[thread overview]
Message-ID: <W4898113245193121124551541@webmail4> (raw)

i think you missed a few things along the way.

i started using byron's rc version < 1.0 around 1990. maybe earlier.
duff's rc was not avaiable to the public in those days. i really 
appreciated having something better than the bourne or bourne-again
shell to use. byron's rc was no "big mistake".

when byron maintained it, it never had any autoconf stuff. it also
had much simpiler builtins. try downloading rc version 1.4 or 1.2
if those things really bother you. btw: it's not necessiary to build 
with readline. i bet there's only 50 lines of conditional code for that.
my favorite recient boner is $version which can't be overwritten.
bogus.

i think you've missed the some important differences:
        x=()
        ~ x () && echo fu

behaves differently in duff's rc vs byron's rc. this is probablly
unintentional, not having side-by-side versions to bakeoff.

        ~ $#x 0 && echo fu

does the same thing, though. byron's rc doesn't support
unicode (anymore? --- i thought this used to work). e.g.
(sorry about the lack of unicode support thorugh this interace.
<alpha> stands for U+03b1, of course.)
        <alpha> = 1
        echo $<alpha>
      -> syntax error

also, internally duff's rc
responds to signals by popping the vm stack down to the interactive
frame. byron's rc finds a good spot and longjmp()s. this 
requires some goofy memory managment and is very sensitive
to changes in the c library / operating environment, etc.

also, the "if not" vs "else" debate. both of these are hacks to get
around the fact that yacc wants to shift another token when presented
with a c-style if-then-else right after then "then" clause. this is 
a problem for an interactive parser. byron's solution was to not allow 
a newline before the else. duff's was to force a newline and call the
else clause "if not".

also, i (and i believe byron and paul haahr) where under the impression
from the paper that

# duff's rc
if (true){
        if (false) {
                echo wierd
        }
}
if not echo broken

would echo broken. the man page for instance says:

          if not command
               The immediately preceding command must have been
               if(list) command. If its condition was non-zero, the
               command is executed.

i just tried this out and i was wrong all these years.
russ cox's comments about a "gratuitus" change makes a lot of sense.

btw, paul haahr's rc's-lovechild-with-scheme shell es uses
        if {stmts} {stmts2} ...
which is just syntatic sugar for
        {stmts} && {stmts2} ...


erik

-----

On 8/19/05, Steve Simon <steve@quintile.net> wrote:
> Not wishing to troll, but genuine interest - why do you prefer a port
> of plan9's rc to a staticially linked version of Byrons rc rewrite?

Because Byron's rc is not conform to Tom Duff's paper and does very
nasty things, the worst is the totally broken if-else syntax, a
sample:

if(foo) {
}
else {
}

is invalid syntax, only

if(foo) {
} else {
}

is valid syntax (why no if not?), if the else branch is supplied in
Byron's rc reimplementation. Beside of that, Byron's rc introduced
many features like readline() support, history support, clunky
builtins etc., which I removed from the source code (beside other
cleanups, like auto*hell removal, you can find my forked/cleaned up
version, which also implements export here:
http://wmi.modprobe.de/snaps/rci-20050809.tar.bz2 (it is based on
rc-1.7.1)).
Also, Byron's shell implements rc-inconform things like `foo as
abbreviation for `{foo} unless foo is a token which does not contain
whitespaces, or the broken flatten operator $^foo instead of the
correct $"foo. The latter annoyences I fixed in rci, but I wasn't able
to fix the if-else handling, because the broken syntax uses some
common grammar tricks also seen in other interpreters which reflect
into the syntax tree walking, - I didn't wanted to replace the tree
walking code in rc(i), thus I lived with the broken if-else syntax.

> For me there is nothing to chose unless you have a lot of scripts from
> a plan9 system that tickle the changes Byron made. I find the differences
> between Plan9 and Linux sed more of a pain.

I think Bryan did a big mistake when designing his rc
standard-incompliant, because that has been the same issue with
sh-style shells already. I could agree that rfork is complicated, and
I could also accept some extensions, but the base language should be
equal in a shell which states to be rc, but which isn't rc in fact,
only some approximation.

Regards,
-- 
  Anselm R. Garbe  ><><  www.ebrag.de  ><><  GPG key: 0D73F361




             reply	other threads:[~2005-08-20 15:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-20 15:25 quanstro [this message]
2005-08-20 17:49 ` Anselm R. Garbe
2005-08-20 21:07   ` Axel Belinfante
2005-08-20 21:23 quanstro
2005-08-20 21:45 ` Anselm R. Garbe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=W4898113245193121124551541@webmail4 \
    --to=quanstro@speakeasy.net \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).