9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Pietro Gagliardi <pietro10@mac.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] How to move to rc from sh/bash
Date: Sun, 10 Feb 2008 12:16:50 -0500	[thread overview]
Message-ID: <41F23396-1019-4C8E-A65A-E42824B0E23B@mac.com> (raw)
In-Reply-To: <599f06db0802100859l2a13a8e7o9d6a492138d44421@mail.gmail.com>

On Feb 10, 2008, at 11:59 AM, Gorka Guardiola wrote:

> On Feb 9, 2008 8:53 AM, Hongzheng Wang <wanghz@gmail.com> wrote:
>> Hi all,
>>
>> 2. In non-interactive use (script programming), what's the main
>> advantages of rc over sh/bash?
>
> Things I like of rc:
>
> In both interactive and non-interactive, spaces do not bite you in rc.
>
> in bash
>
> if [ $bla -eq $otherbla ] ; fi endif... ahhh, I can´t remember the
> syntax and get the spaces wrong,

The proper is

if [ $bla -eq $otherbla ]; then
	:
fi

The advantage of rc is that that : is not necessary!

Oh, and let's not forget what happens when bla or otherbla is nil! In  
rc,
	if (~ $bla $otherbla) { }
is all that is needed - no hooks.
>
> Someone else said it, only one quoting simbol
> (what does " bla \$e'o" do on bash?, I just invented it, but every  
> time I see
> double qoutes I start trembling)

It produces the string ' bla$e''o' in rc syntax. The one thing I like  
about two quoting styles  in the Bourne shell is that I can use  
escape sequences. The one thing I dislike about bash is that bash  
fucks up this quote system.
>

And here is my 2 cents:

- List objects are STANDARD (bash/kornshell arrays are not)
	x=(a b c)
- The seq statement is standard
	for (i in `{seq 1 10}) echo $i
- Removable functions
	fn x { echo 4 }
	fn x
	x=4
- >[] piping syntax is much more intuitive
- |[2] to pipe arbitrary file descriptors. One time, to skim through  
errors from gcc to find out if I had mistyped a member of a struct, I  
had to do
	gcc a_file_in_my_os.c 2>&1 | grep member
   In rc:
	8c a_file_in_my_os.c |[2] grep member
- Empty condition bodies! while(){echo y} is the yes command. It's  
much more terse.
- aux/getflags is faster than while getopt (no loop involved)
	My next plan is to rewrite all of /rc/bin to use aux/getflags. Any  
objections?
- The trap statement is gone - goodbye confusing hooks and no way of  
telling signal 1 from a command/function called 1
	Instead, you define functions sigterm and sigkill (I think)

And what I dislike:
- >[2=] is not the same as >[2]/dev/null (some programs crash with  
the former


  reply	other threads:[~2008-02-10 17:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-09  7:53 Hongzheng Wang
2008-02-09  8:01 ` mattmobile
2008-02-09  8:41   ` Hongzheng Wang
2008-02-09  8:57     ` mattmobile
2008-02-09  9:00 ` erik quanstrom
2008-02-09  9:21   ` Hongzheng Wang
2008-02-09 10:11 ` Charles Forsyth
2008-02-09 10:27   ` Lluís Batlle
2008-02-09 15:06     ` Uriel
2008-02-09 17:54     ` Charles Forsyth
2008-02-09 21:59       ` geoff
2008-02-09 13:00   ` Anthony Sorace
2008-02-10 16:59 ` Gorka Guardiola
2008-02-10 17:16   ` Pietro Gagliardi [this message]
2008-02-10 17:47     ` erik quanstrom
2008-02-10 18:12     ` Martin Neubauer
2008-02-11 15:04       ` erik quanstrom
2008-02-11 23:03         ` Martin Neubauer
2008-02-11 23:25           ` Pietro Gagliardi
2008-02-20 15:04             ` maht
2008-02-20 15:08               ` Federico G. Benavento
2008-02-20 15:24               ` erik quanstrom
2008-02-20 15:55                 ` maht
2008-02-11 23:59       ` Uriel
2008-02-12 11:57         ` Martin Neubauer

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=41F23396-1019-4C8E-A65A-E42824B0E23B@mac.com \
    --to=pietro10@mac.com \
    --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).