[comp.sys.amiga.tech] ksh-like shell for the Amiga available

koren@hpfelg.HP.COM (Steve Koren) (11/08/89)

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.

kudla@pawl.rpi.edu (Robert J. Kudla) (11/09/89)

I have one question (a question which caused me to stop using Matt
Dillon's csh program, which I feel is vastly superior to anything else
I've used). How friendly is it with 1.3? Can I use 1.3 environment
variables and resident commands? And will it be re-entrant itself?

Enquiring minds want to know.
-- 
Robert Jude Kudla   <kudla@pawl.rpi.edu> <kudla@acm.rpi.edu> <fw3s@RPITSMTS>

                       What noisy cats are we.

koren@hpfelg.HP.COM (Steve Koren) (11/09/89)

More Ash info:
--------------

After receiving no less than a dozen mail messages about Ash in 1 day, I
thought I might post a few clairifications here:

   1) Ash will be available in comp.binaries.amiga soon.  I can't make it
      available for FTP, sorry.  Security restrictions here prevent that.
      Perhaps someone else can, if they'd be willing to always keep the
      most recent version there.

   2) You can use Ash now, but consider it a beta version.  There are a
      few things I need to add yet, like cp -r and rm -r, for example,
      and more of the Unix utilities like sort, grep, cut, and paste.

The "real" release of Ash will have the cp -r and rm -r commands.  Also,
I have completed two other things that will be in the "real" version -
using <esc>= to list the files matching a pattern, and <esc>* to insert
them in the command line (as in ksh).  For example, suppose you have
typed, this (the _ is the cursor)

    [dh0:]: ll *.c_

and type <esc>=.  Ash will display all the files ending in .c for you,
and then re-display your command line, so the display will look like this:

    [dh0:]: ll *.c
       1) my_file.c
       2) my_other_file.c
       3) foo.c
    [dh0:]: ll *.c_

Also, using <esc>* will insert those files directly into the command line:

    [dh0:]: ll *.c
    [dh0:]: ll my_file.c my_other_file.c foo.c_

Those features are not in the beta version, though, so hang on a bit.
They'll be there.  I hope to have the more stable "real" one out in a
few weeks, but you can use the beta version in the meantime, and I'd
appriciate any suggestions for improvement.

        - steve (koren@hpfela.HP.COM)

PS - Our site does not get comp.binaries.amiga, so I won't be able to
     tell when Ash has been posted.

peter@sugar.hackercorp.com (Peter da Silva) (11/10/89)

In article <13920006@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes:
> 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:

Why didn't you start with the freeware "ash" shell, a clone of the extended
bourne shell for UNIX? That way you could keep the syntax compatible.

(I know, 20-20 hindsight)
-- 
Peter "Have you hugged your wolf today" da Silva <peter@sugar.hackercorp.com>
`-_-' "IT'S THE TWO GODDAMNED CULTURES AGAIN !*! Bit-brained nerdery on one
 'U`   side, effete fin-de-siecle malaise on the other. And kingdoms of hybrid
       delight abandoned in the middle."  -- burns@latcs1.oz (Jonathan Burns)

koren@hpfelg.HP.COM (Steve Koren) (11/10/89)

> I have one question (a question which caused me to stop using Matt
> Dillon's csh program, which I feel is vastly superior to anything else
> I've used). How friendly is it with 1.3? Can I use 1.3 environment
> variables and resident commands? And will it be re-entrant itself?

It will use 1.3 environment variables with the 'import' and 'export'
commands.  'import' reads an env variable into an Ash variable of the
same name, and 'export' creates an env variable from an Ash variable.
I thought Matt's shell did this too, but maybe I'm wrong.

I'm not sure about 1.3 resident commands.  I use ARP to execute programs;
I think that might do it.  I'd have to check.

The beta (1.0) version of Ash can not be made resident.  The "real"
one may very well be.  Lattice 5.xx provides a way to do this, or
so they claim, with little effort.  I haven't tried it yet.  If it
works, and is easy, I'll do it.

       - steve

koren@hpfelg.HP.COM (Steve Koren) (11/10/89)

One more note about Ash: the next (real) release may be called something
else.  Someone brought it to my attention that there is another Amiga
shell called 'ash' as well.  I don't know what it does or anything about
it, but I may change the name of my 'Ash' to something else.  This will
temporarily cause some confusion, but should lessen it in the long run.

Anyway, I'd have to find a suitable name.  'ksh' (for Koren's shell)
is already taken....

        - steve (koren@hpfela.HP.COM)

tadguy@cs.odu.edu (Tad Guy) (11/11/89)

In article <13920007@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes:
> Ash will be available in comp.binaries.amiga soon.  I can't make it
> available for FTP, sorry.  Security restrictions here prevent that.
> Perhaps someone else can, if they'd be willing to always keep the
> most recent version there.

Everything that appears in comp.binaries.amiga is available via ftp
from xanth.cs.odu.edu as soon as it arrives at xanth...

	...tad

koren@hpfelg.HP.COM (Steve Koren) (11/12/89)

> Why didn't you start with the freeware "ash" shell, a clone of the extended
> bourne shell for UNIX? That way you could keep the syntax compatible.

> (I know, 20-20 hindsight)

Hmm.  The only other 'ash' I know about is the 'arp' one, and it is far
from being a clone of bourne shell.  In fact, my 'Ash' is much closer to
that.  Maybe you're talking about something else?

Anyhow, I didn't know about that when I wrote Ash.  Also, it would have
been *significantly* more effort to re-write theirs to support all the things
I wanted.  And then, if I did extend theirs, I'd probably have to change
it every time they came out with a new version, etc.  Its much easier for
me this way, and since I have little free time as it is, effort was an
important consideration.  There are some disadvantages as well; for example,
it will take a few releases before all the bugs are worked out of Ash.  But
in the long run, I think this is a better choice.  Its just my opinion, of
course, so there's nothing to stop someone else from extending the arp
'ash'.
 
   - steve (koren@hpfela.HP.COM)

koren@hpfelg.HP.COM (Steve Koren) (11/12/89)

Yet more info:
-------------

A few more bits of information.  The next Ash (1.1) will be 'pure' so you can
make it resident.  This was quite easy to do, and I have it working now.
Its kinda neat since you can make the 'newshell' command automatically fire
up Ash when it makes the new window.  Then, you can set the 'LOGOUT' variable
in Ash to be 'endcli', and the window automatically disappears when Ash
exits.
 
There seems to be a problem with the ArpExit() call that I was originally
using.  It often hangs the CLI window.  I yanked it from the next version,
so 'exit' is reliable again.  (I think maybe it doesn't work since it claims
it closes the arp.library, which may not be a cool thing to do when the
code that does it is *in* in the arp.library).
 
Also, there seems to be a few bugs with the export and getenv Ash commands.
I don't *think* they are Ash bugs, though.  For example, the following
code fails under Lattice 5.02:
 
    #include <stdio.h>
    main(argc, argv)
       int argc; char *argv[];
    {
       putenv("foo2=barbar");
       printf("%s\n", getenv("foo2"));
    }
 
I get really wierd results, anything from 'barbaro2' to 'barbar:foo2'.
If this is really a Lattice bug (unless somebody sees something here I
don't), I can't make getenv and export work right until it is fixed.
(I've tried malloc()ing the string passed to putenv(), which doesn't help
at all).
 
Also, I should mention that Ash requires 1.3.  I haven't tested it at
all under 1.2, but I suspect it won't run.  It depends on a number of
1.3 things.

     - steve (koren@hpfela.HP.COM)

peter@sugar.hackercorp.com (Peter da Silva) (11/18/89)

The other "ash" isn't an Amiga shell. It's a bourne shell clone.
-- 
Peter "Have you hugged your wolf today" da Silva <peter@sugar.hackercorp.com>
`-_-'
 'U`
       "I am the ghost of aquariums past" -- Robotman.

peter@sugar.hackercorp.com (Peter da Silva) (11/18/89)

In article <13920010@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes:
> > Why didn't you start with the freeware "ash" shell, a clone of the extended
> > bourne shell for UNIX? That way you could keep the syntax compatible.

> Hmm.  The only other 'ash' I know about is the 'arp' one, and it is far
> from being a clone of bourne shell.  In fact, my 'Ash' is much closer to
> that.  Maybe you're talking about something else?

Yep, I sure am. I dislike the ARP approach and haven't paid much attention to
them. I'd never heard of their "ash". The one I'm talking about is a bourne
shell clone on UNIX. Now why would one clone the bourne shell on UNIX? To
enhance it, of course, like Korn did. This one is less ambitious than Korn's,
it merely provides the System V Bourne shell functionality for Pre-SYSV UNIX.
But it's Freeware.

Wouldn't it be nice to have a real UNIX shell source to start with? I can try
digging it up if you like.
-- 
Peter "Have you hugged your wolf today" da Silva <peter@sugar.hackercorp.com>
`-_-'
 'U`
       "I am the ghost of aquariums past" -- Robotman.

chekmate@athena.mit.edu (Adam Kao) (11/19/89)

In article <13920009@hpfelg.HP.COM> koren@hpfelg.HP.COM (Steve Koren) writes:
]
]Anyway, I'd have to find a suitable name.  'ksh' (for Koren's shell)
]is already taken....
]
]        - steve (koren@hpfela.HP.COM)

How about "kosh" for Koren's shell?

Adam "I hate names I can't pronounce" Kao

barrett@jhunix.HCF.JHU.EDU (Dan Barrett) (11/20/89)

In article <4565@sugar.hackercorp.com> peter@sugar.hackercorp.com (Peter da Silva) writes:
>The other "ash" isn't an Amiga shell. It's a bourne shell clone.

	Remember that L:ASH is the ARP Shell.

                                                        Dan

 //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
| Dan Barrett     -      Systems Administrator, Computer Science Department |
| The Johns Hopkins University, 34th and Charles Sts., Baltimore, MD  21218 |
| INTERNET:   barrett@cs.jhu.edu           | UUCP:   barrett@jhunix.UUCP    |
| COMPUSERVE: >internet:barrett@cs.jhu.edu | BITNET: barrett@jhuvms.bitnet  |
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////

koren@hpfelg.HP.COM (Steve Koren) (11/21/89)

> >The other "ash" isn't an Amiga shell. It's a bourne shell clone.

> 	Remember that L:ASH is the ARP Shell.

     (My) Ash has been renamed to SKsh for the 1.2 (real, non beta)
     release.

             - steve