rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Carlo Strozzi <carlos@linux.it>
To: rc@hawkwind.utcs.toronto.edu
Subject: Re: building rc on QNX4
Date: Mon, 8 May 2000 09:28:02 -0400	[thread overview]
Message-ID: <20000508152802.A12803@polka.mi.linux.it> (raw)
In-Reply-To: <BxMAABh7Fjm+LgcA@ltsun0.star.le.ac.uk>; from tjg@star.le.ac.uk on Mon, May 08, 2000 at 04:29:54AM -0400

[-- Attachment #1: Type: text/plain, Size: 2312 bytes --]

On Mon, May 08, 2000 at 04:29:54AM -0400, Tim Goodwin wrote:
 >> A more important issue IMHO is whether Rc should provide a built-in
 >> read function, similar to the one offered by most Bourne shells;
 >
 >There is no *need* to make `read' a builtin: see the EXAMPLES file in
 >the distribution for an alternative.  One of rc's design goals is to
 >avoid unnecessary builtins.  So, no, I don't think this is likely to
 >happen.
 >

Unfortunately the example provided does not work the way 'read' does,
and is an extra-process that needs to be spawned for each input line.
                                                                     
 >> one is whether it will ever make it possible not to export everything to
 >> the environment by default.
 >
 >I brought this up a few months ago, and the consensus seemed to be that
 >the current scheme works well enough in practice.  Have you encountered
 >a problem?

hmm ... not really. Mine is just a general concern. Currently I
initialize every variable that I'm going to use in a script, right
at the beginning of the program, somewhat like what you do with C
whan you declare things first.  That is because unless I maintain a
global name-space I never know what a variable is going to contain 
when the program is called. Having a clean environment would
be desirable in general.

Anyway, the above is another minor issue, it may as well be that the
current scheme is ok. What I _really_ miss is a 'read', or 'line',  
function, for record-oriented input, and I think this feeling is
shared also by others. While things like 'test' are rarely called   
inside a loop, reading lines from a file is the opposite, and spawning
an external process on each line sucks, especially when one uses
the shell for writing Web CGI scripts, like I do.

Beside all that, I am a long-time (Bourne) shell user, and I whish I
had uncovered rc before :-)

Anyway, just to give my two-cent and not just ask for things :-), here
are a couple of functions to emulate often-used external processes like
basename(1) and dirname(1). I've tried to mimic the respective utilities
as closely as I could. Bug-fixes are welcome :-)

bye  -carlo
-- 
I can read MIME or uuencoded e-mail attachments in PDF, Postscript, HTML,
RTF or text formats. Please do not send Word or Excel files. 

[-- Attachment #2: rcstuff.txt --]
[-- Type: text/plain, Size: 612 bytes --]

#
# Emulate dirname(1)
#

fn DirName {
   ~ $1 () && { echo DirName: too few arguments >[1=2] ; return 1 }
   ~ $1 '' .* && { echo . ; return }
   ~ $1 / && { echo / ; return }
   x=() y=() {
      x = ``(/) {echo -n $1}
      ~ $1 /* && ~ $x(2) () && { echo / ; return }
      ~ $x(2) () && { echo . ; return } 
      * = $x
      while (!~ $#* 0 1) { y = $y/$1 ; shift }
      echo $y
   }
}

#
# Emulate basename(1)
#

fn BaseName {
   ~ $1 () && { echo BaseName: too few arguments >[1=2] ; return 1 }
   ~ $1 '' / && return
   x = () {
      x = ``(/) {echo -n $1}
      echo $x($#x)
   }
}

# End of stuff.

  parent reply	other threads:[~2000-05-08 22:52 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <sroberts@uniserve.com>
2000-04-26 15:02 ` Sam Roberts
2000-04-27 16:56   ` Scott Schwartz
2000-04-27 20:41     ` Sam Roberts
2000-04-28  7:28       ` vrl (was: Re: building rc on QNX4) Gert-Jan Vons
2000-04-28 18:38         ` Sam Roberts
2000-05-02  8:16           ` Gert-Jan Vons
2000-04-28 19:03         ` rc not session leader? Sam Roberts
2000-04-27 17:39   ` building rc on QNX4 Carlo Strozzi
2000-05-02 14:41     ` Tim Goodwin
2000-05-04 15:18       ` Carlo Strozzi
2000-05-08  8:29         ` Tim Goodwin
2000-05-08  8:58           ` Chris Siebenmann
2000-05-08  9:15             ` Tim Goodwin
2000-05-08 23:25               ` Stephen Tell
2000-05-10  0:37                 ` builtins Scott Schwartz
2000-05-12  7:22                   ` builtins Carlo Strozzi
2000-05-08 11:50           ` building rc on QNX4 David Luyer
2000-05-08 13:28           ` Carlo Strozzi [this message]
2000-05-04  8:45 Byron Rakitzis
2000-05-06 10:28 ` Carlo Strozzi
2000-05-07 17:46   ` Paul Haahr
2000-05-08  8:01     ` Carlo Strozzi
2000-05-06 16:35 ` Jeremy Fitzhardinge
2000-05-04 13:46 Sam Roberts
2000-05-06 21:47 Byron Rakitzis
2000-05-08 10:19 Bengt Kleberg
2000-05-08 15:15 Smarasderagd
2000-05-09  8:22 ` Carlo Strozzi
2000-05-08 15:23 Sam Roberts
2000-05-09  8:25 ` Carlo Strozzi
2000-05-09  4:34 Smarasderagd
2000-05-11 12:26 ` Gert-Jan Vons

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=20000508152802.A12803@polka.mi.linux.it \
    --to=carlos@linux.it \
    --cc=carlos@texne.com \
    --cc=rc@hawkwind.utcs.toronto.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).