home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff279.lzh / Ash / Diffs.doc < prev    next >
Text File  |  1989-11-20  |  7KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                                  Ash/ksh Differences
  17.  
  18.                                          ASH
  19.  
  20.                            A ksh-like Shell for the Amiga
  21.  
  22.                                      Version 1.0
  23.  
  24.  
  25.                                   (Copyright) 1989 
  26.  
  27.                                      Steve Koren
  28.  
  29.                                   November 7, 1989
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.           Introduction
  74.  
  75.             This document describes some of  the  differences  between  Ash
  76.             and ksh under Unix.  It does not even begin to cover them  all.
  77.             If  you  need  to  have  specific  information,   compare   the
  78.             appropriate sections of the two manuals.
  79.  
  80.             In general, scripts may be written which run under  either  Ash
  81.             or ksh by testing the $SHELL parameter:
  82.  
  83.                if [ "$SHELL" = 'ash' ]
  84.                then
  85.                  echo 'do some Ash/AmigaDos specific things here'
  86.                elif [ "$SHELL" = 'ksh' ]
  87.                then
  88.                  echo 'do some ksh/UNIX specific things here'
  89.                fi
  90.  
  91.  
  92.           Differences List
  93.  
  94.             Alias and Function Resolution
  95.  
  96.                Ash  resolves  alias  and  function  names  when  they   are
  97.                logically encountered.  ksh  resolves  them  when  they  are
  98.                physically encountered.  This leads to different  behaviours
  99.                in functions.   For  example,  in  Ash,  you  can  define  a
  100.                function that uses  an  alias  that  you  define  after  the
  101.                function.  As long  as  the  alias  is  defined  before  the
  102.                function is executed  (but  not  necessarily  before  it  is
  103.                defined), Ash will execute the alias normally.  In  ksh,  on
  104.                the other hand, the alias must be defined as such  when  the
  105.                function is defined, not when it is executed.
  106.  
  107.  
  108.             Assignment Syntax
  109.  
  110.                Ash permits spaces to surround  the  '='  in  an  assignment
  111.                statement.  ksh does not.
  112.  
  113.  
  114.             ${var:val} Operations
  115.  
  116.                ksh has a bunch of  variable  binding  operators  that  look
  117.                like the above, and permit tests and assignments to be  made
  118.                in one step.  Ash does not support any of these.
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.           ASH Amiga Shell               Page 2         Ash/ksh Differences
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.             vi mode
  140.  
  141.                ksh has a command line editing mode that is  similar  to  vi
  142.                bindings.  Ash has only the emacs bindings.  I may,  in  the
  143.                future, permit user defined bindings, but this is  not  high
  144.                on my priority list of things to do.
  145.  
  146.                In addition, Ash emacs command line editing, although  quite
  147.                useful, is limited compared to that of ksh.   Ash  does  not
  148.                permit cut and paste between  lines,  etc.   A  few  of  the
  149.                commands  also  work  differently  (such   as   the   search
  150.                command).
  151.  
  152.  
  153.             In-line parameter assignment
  154.  
  155.                ksh permits variables to be assigned to while being used  as
  156.                a parameter.  For example,
  157.  
  158.                  export COLUMNS=80
  159.  
  160.                Ash does not permit this.  You must perform  the  assignment
  161.                and export separately.
  162.  
  163.  
  164.             Job Control
  165.  
  166.                ksh has job control.  Ash does not.
  167.  
  168.  
  169.             Path Separator Character
  170.  
  171.                ksh uses ':' as  a  path  separator  character.   Since  the
  172.                colon is a legal character in AmigaDos path names,  a  comma
  173.                is used instead.
  174.  
  175.  
  176.             Function Definition Syntax
  177.  
  178.                The Ash function  definition  syntax  using  the  'function'
  179.                keyword is compatible with ksh,  but  ksh  also  permits  an
  180.                alternate syntax using 'function() { }' that Ash does not.
  181.  
  182.  
  183.             Set vs. Options
  184.  
  185.                ksh uses the 'set' keyword  to  set  options  to  the  shell
  186.                itself.  Ash  uses  'set'  to  list  alias,  variables,  and
  187.                functions.  Ash uses  the  'option'  command  to  set  shell
  188.                options.  These options are, with  only  a  few  exceptions,
  189.                different from their ksh counterparts.
  190.  
  191.  
  192.  
  193.  
  194.  
  195.           ASH Amiga Shell               Page 3         Ash/ksh Differences
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.             Scoping Rules
  206.  
  207.                The Ash scoping rules are different than the  scoping  rules
  208.                in in ksh.  Ksh supports the  'typeset'  keyword  to  create
  209.                local variables; Ash controls this with an option  flag  and
  210.                the 'local' command.  In addition, Ash local  variables  can
  211.                be turned off entirely to emulate the sh scoping rules.
  212.  
  213.  
  214.             Builtin Commands
  215.  
  216.                Ash accomplishes many things with builtin commands that  ksh
  217.                accomplishes with external binaries.  In addition, Unix  has
  218.                boatloads more of these commands  than  the  Amiga  and  Ash
  219.                combined do or ever will.   If  its  on  Unix,  and  not  on
  220.                AmigaDos, you'll probably have to write it if you want it.
  221.  
  222.                In addition, many  of  the  Ash  commands  accept  different
  223.                parameters than  either  Unix  counterparts  with  the  same
  224.                name.  Some of  them  also  act  differently;  for  example,
  225.                'read' in Unix reads a single parameter  separated  by  IFS,
  226.                while 'read' in Ash reads a whole line.
  227.  
  228.  
  229.             case...esac statement
  230.  
  231.                ksh supports a case...esac statement that Ash does  not.   I
  232.                can add this fairly easily, but I haven't done it yet  since
  233.                1) it  would  make  Ash  even  larger,  and  2)  it  can  be
  234.                simulated by using if...elif...else...fi statements.
  235.  
  236.  
  237.             until...do...done statement
  238.  
  239.                Ash does not support this either.   I was also not in a  big
  240.                hurry to add  it,  since  it  is  simply  a  while..do..done
  241.                statement with the test automatically inverted.
  242.  
  243.  
  244.             Parameter Breaks
  245.  
  246.                Ash breaks parameters in different  places  than  ksh.   For
  247.                example, 'foo'$foo is one parameter in ksh, but two in  Ash.
  248.                To make it one in Ash, use double quotes  around  the  whole
  249.                expression: "foo$foo", or use $(concat "foo" "$foo").
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.           ASH Amiga Shell               Page 4         Ash/ksh Differences
  262.  
  263.  
  264.  
  265.