[comp.unix.shell] Bourne shell functions

rob@meaddata.com (Robert E. Lancia) (06/22/91)

I'm looking for comments/suggestions/flames concerning the following:

One of our systems is a Sequent computer running DYNIX V3.0.17.v3.
(DYNIX is strange in itself, in that it has completely separate
AT&T and UCB universes, both of which IMHO seem incomplete.)  Anyway,
in trying to write part of a simple Bourne shell script, I found that
their shell doesn't support functions and I came up with a work-around.


As a trivial example consider a function for clearing the screen, 
listing files, and getting confirmation to continue.

#
#  normal function declaration        my work around declaration
#  ===========================        ==========================
#      list_files ()                  list_files='
#      {                                  clear;
#          clear                          echo "Files:";
#          echo "Files:"                  ls $file_dir;
#          ls $file_dir                   echo "Hit <Enter> key";
#          echo "Hit <Enter> key"         read dummy;
#          read dummy                 '
#      }
#
#      Invoked as                     Invoked as
#      ==========                     ==========
#      .  .  .                        .  .  .
#      list_files                     eval $list_files
#      .  .  .                        .  .  .
#

The simple examples I've tried all seem to work, and I can't come up
with a scenario in which won't work.

Comments? / Suggestions? / Problems?

Rob.
--
|Robert Lancia                 | The above opinions    | Mead Data Central
|(513) 297-2560                | may not necessarily   | Data Services Division
|rob@pmserv.meaddata.com       | be MDC's.  Heck, they | P.O. Box 308
|...!uunet!meaddata!pmserv!rob | may not even be mine. | Dayton, Ohio  45401

rob@meaddata.com (Robert E. Lancia) (06/22/91)

Following up to my own article ...

In article <4973@meaddata.meaddata.com> I write:
>
>One of our systems is a Sequent computer running DYNIX V3.0.17.v3.
>(DYNIX is strange in itself, in that it has completely separate
>AT&T and UCB universes, both of which IMHO seem incomplete.)  Anyway,
>in trying to write part of a simple Bourne shell script, I found that
>their shell doesn't support functions and I came up with a work-around.
>
  [ . . . example deleted . . . ]
>
>The simple examples I've tried all seem to work, and I can't come up
>with a scenario in which [it] won't work.
      ^^^^^^^^^^^^^^^^^^^^     ^^^^^^^^^^
... except of course, in dealing with parameters.  The work-around I
described won't work with parameters (at least, not as given.) 
Parameters to these "functions" aren't a major concern of mine for
this script, though.


Other comments, etc?


Rob.
--
|Robert Lancia                 | The above opinions    | Mead Data Central
|(513) 297-2560                | may not necessarily   | Data Services Division
|rob@pmserv.meaddata.com       | be MDC's.  Heck, they | P.O. Box 308
|...!uunet!meaddata!pmserv!rob | may not even be mine. | Dayton, Ohio  45401

pauld@stowe.cs.washington.edu (Paul Barton-Davis) (06/22/91)

In article <4973@meaddata.meaddata.com> rob@pmserv.meaddata.com writes:
>
>I'm looking for comments/suggestions/flames concerning the following:
>
>One of our systems is a Sequent computer running DYNIX V3.0.17.v3.
>(DYNIX is strange in itself, in that it has completely separate
>AT&T and UCB universes, both of which IMHO seem incomplete.)  Anyway,
>in trying to write part of a simple Bourne shell script, I found that
>their shell doesn't support functions and I came up with a work-around.
>
>  [ example deleted ]
>
>The simple examples I've tried all seem to work, and I can't come up
>with a scenario in which won't work.
>
>Comments? / Suggestions? / Problems?
 
If you use /usr/att/bin/sh, you won't need the workaround. Why Sequent
had to supply 2 shells, one of which lacks a completely independent
piece of the other, is beyond me. But it works - I use it any time I
need a Bourne shell rather than bash, and I *only* work in the BSD
universe.