home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
336.lha
/
Ash
/
Diffs.doc
< prev
next >
Wrap
Text File
|
1989-12-27
|
7KB
|
265 lines
Ash/ksh Differences
ASH
A ksh-like Shell for the Amiga
Version 1.0
(Copyright) 1989
Steve Koren
November 7, 1989
Introduction
This document describes some of the differences between Ash
and ksh under Unix. It does not even begin to cover them all.
If you need to have specific information, compare the
appropriate sections of the two manuals.
In general, scripts may be written which run under either Ash
or ksh by testing the $SHELL parameter:
if [ "$SHELL" = 'ash' ]
then
echo 'do some Ash/AmigaDos specific things here'
elif [ "$SHELL" = 'ksh' ]
then
echo 'do some ksh/UNIX specific things here'
fi
Differences List
Alias and Function Resolution
Ash resolves alias and function names when they are
logically encountered. ksh resolves them when they are
physically encountered. This leads to different behaviours
in functions. For example, in Ash, you can define a
function that uses an alias that you define after the
function. As long as the alias is defined before the
function is executed (but not necessarily before it is
defined), Ash will execute the alias normally. In ksh, on
the other hand, the alias must be defined as such when the
function is defined, not when it is executed.
Assignment Syntax
Ash permits spaces to surround the '=' in an assignment
statement. ksh does not.
${var:val} Operations
ksh has a bunch of variable binding operators that look
like the above, and permit tests and assignments to be made
in one step. Ash does not support any of these.
ASH Amiga Shell Page 2 Ash/ksh Differences
vi mode
ksh has a command line editing mode that is similar to vi
bindings. Ash has only the emacs bindings. I may, in the
future, permit user defined bindings, but this is not high
on my priority list of things to do.
In addition, Ash emacs command line editing, although quite
useful, is limited compared to that of ksh. Ash does not
permit cut and paste between lines, etc. A few of the
commands also work differently (such as the search
command).
In-line parameter assignment
ksh permits variables to be assigned to while being used as
a parameter. For example,
export COLUMNS=80
Ash does not permit this. You must perform the assignment
and export separately.
Job Control
ksh has job control. Ash does not.
Path Separator Character
ksh uses ':' as a path separator character. Since the
colon is a legal character in AmigaDos path names, a comma
is used instead.
Function Definition Syntax
The Ash function definition syntax using the 'function'
keyword is compatible with ksh, but ksh also permits an
alternate syntax using 'function() { }' that Ash does not.
Set vs. Options
ksh uses the 'set' keyword to set options to the shell
itself. Ash uses 'set' to list alias, variables, and
functions. Ash uses the 'option' command to set shell
options. These options are, with only a few exceptions,
different from their ksh counterparts.
ASH Amiga Shell Page 3 Ash/ksh Differences
Scoping Rules
The Ash scoping rules are different than the scoping rules
in in ksh. Ksh supports the 'typeset' keyword to create
local variables; Ash controls this with an option flag and
the 'local' command. In addition, Ash local variables can
be turned off entirely to emulate the sh scoping rules.
Builtin Commands
Ash accomplishes many things with builtin commands that ksh
accomplishes with external binaries. In addition, Unix has
boatloads more of these commands than the Amiga and Ash
combined do or ever will. If its on Unix, and not on
AmigaDos, you'll probably have to write it if you want it.
In addition, many of the Ash commands accept different
parameters than either Unix counterparts with the same
name. Some of them also act differently; for example,
'read' in Unix reads a single parameter separated by IFS,
while 'read' in Ash reads a whole line.
case...esac statement
ksh supports a case...esac statement that Ash does not. I
can add this fairly easily, but I haven't done it yet since
1) it would make Ash even larger, and 2) it can be
simulated by using if...elif...else...fi statements.
until...do...done statement
Ash does not support this either. I was also not in a big
hurry to add it, since it is simply a while..do..done
statement with the test automatically inverted.
Parameter Breaks
Ash breaks parameters in different places than ksh. For
example, 'foo'$foo is one parameter in ksh, but two in Ash.
To make it one in Ash, use double quotes around the whole
expression: "foo$foo", or use $(concat "foo" "$foo").
ASH Amiga Shell Page 4 Ash/ksh Differences