🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #2043

ksh-like shell for the Amiga available (beta)

#2043
From: Steve Koren
Date: Wed, 08 Nov 1989 15:01
121 lines
4950 bytes
ksh-like shell for the Amiga available (beta release)
-----------------------------------------------------

I have just finished a beta version of 'Ash', a ksh-like shell for
the Amiga.  I wrote it because I wanted to have a similar environment
at work and at home.  Ash supports a bunch of things, a few of which
I'll list here:

    * Filename completion using <esc><esc> or <tab>

    * Shell aliases and functions.  Functions can have local variables
      and even local aliases and local functions, like this:

          function outer {
              function inner {
                  echo "inner function was passed $# parameters"
              }
              inner $*
              a_local_variable="$0"
          }

    * Ash maps Unix style filenames to AmigaDos style filenames.  It
      allows the use of a dot to mean the current directory, two dots
      to mean the directory above this one, a tilde to mean the home
      directory, and absolute paths beginning with /.  Thus

          /foo/bar/not      ->becomes->     :foo/bar/not
          ../../foo/../bar  ->becomes->     //foo//bar
         ~/foo              ->becomes->     $HOME/foo
         ./foo              ->becomes->     $PWD/foo

    * A sorta complete emacs-style command line editor.  It will scroll
      the line horizontally when you run off the end, and supports searches
      using ^r, word forward, back, and delete, 'operate' using ^o, and
      most of the rest of the basic editing stuff from ksh.  Lacking is
      cut and paste using delete + ^y.

    * Ash will exist happily with scripts from other shells.  If you
      put:

         #!c:my_other_shell

      As the first line of your script, Ash will use my_other_shell to
      run the script (as in Unix).  If the script bit is set, Ash
      will run the script without any special commands.  You just type
      its name.  As will search the search path for scripts, too.

    * The Ash syntax is close to that of ksh.  For example, this works
      either place, and should give you a flavor of what Ash is like.
      You can use it in a script or type it from the command line:

        function install_foo {
           if [ $# -ne 1 ]
           then
               echo 'this script requires exactly one parameter'
               return
           fi

           if [ -d /bin -a ! -f /bin/foo ]
           then
               cp $1 /bin/foo
               echo 'installed /bin/foo!'
           elif [ ! -d /bin ]
           then
               echo 'no /bin directory found'
           else
               echo '/bin/foo already existed!'
           fi
        }

     * Ash supports re-direction and piping over complex as well as simple
       commands.  Thus,

         for file in *.[ch]
         do
            echo "file = $file, which is" $(expr length $file) "chars long"
         done > my_file

       works, as you can re-direct the output of the whole loop.  This
       works for functions, aliases, and scripts, too.

     * Ash supports command substition.  Thus,

         a=`basename $my_file`
         path_name=$(which $my_file)

       all work with the desired effect.  The second method is recommended
       both by ksh and Ash over the first, since its easier to read and
       nest.  You can even put complex commands in substition marks:

          echo $( if [ "$var1" = "$var2" ]
                  then
                      echo "Yup, they're equal"
                  fi
                )

     * You can define the function keys to insert characters.

     * Ash keeps a history list, and supports '!' and '!!' as in csh (with
       a few differences).

     * Ash supports sub-shell execution:

        { read a; read b } <my_file

There are also some things ksh does that Ash does not.  Ash does not
support ${var} as ksh does.  It does not currently support the case
statement (although that will be coming probably for the next release).
Also, there is no vi editing mode as in ksh.  There are a few other things
as well, but its reasonably complete.

I will be sending Ash to the moderator of comp.binaries.amiga tonight,
so it will be there as soon as he gets a chance to post it.  Ash does
more than I have posted above, but that should at least give you a good
idea of what it's like.  I hope it will be useful to those who wish to
have a ksh-like shell on their Amiga.

       - steve (koren@hpfela.HP.COM)

PS - oh yeah, its freely distributable, too.
Technical Details
Message-ID: <13920006@hpfelg.HP.COM>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!hpfcso!hpfelg!koren

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!hplabs!hpfcso!hpfelg!koren
From: koren@hpfelg.HP.COM (Steve Koren)
Newsgroups: comp.sys.amiga.tech
Subject: ksh-like shell for the Amiga available (beta)
Message-ID: <13920006@hpfelg.HP.COM>
Date: 8 Nov 89 15:01:35 GMT
Organization: HP Elec. Design Div. -FtCollins
Lines: 121