home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk381.lzh / SKsh / Diffs.doc < prev    next >
Text File  |  1990-10-20  |  6KB  |  265 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                                 SKsh/ksh Differences
  17.  
  18.                                         SKsh
  19.  
  20.                            A ksh-like Shell for the Amiga
  21.  
  22.                                      Version 1.6
  23.  
  24.  
  25.                                (Copyright) 1989, 1990
  26.  
  27.                                      Steve Koren
  28.  
  29.                                    October 4, 1990
  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 SKsh
  76.             and ksh  under Unix.  It does not even begin to cover them all.
  77.             If you need  to  have  specific information, compare the appro-
  78.             priate sections of the two manuals.
  79.  
  80.             In  general, scripts may be written which run under either SKsh
  81.             or ksh by testing the $SHELL parameter:
  82.  
  83.                if [ "$SHELL" = 'sksh' ]
  84.                then
  85.                  echo 'do some SKsh/AmigaDos specific things here'
  86.                elif [ "$SHELL" = '/bin/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.                SKsh  resolves alias and  function names when they are logi-
  97.                cally encountered.   ksh  resolves them when they are physi-
  98.                cally encountered.  This  leads  to  different behaviours in
  99.                functions.  For  example, in SKsh, you can define a function
  100.                that uses an alias that  you  define after the function.  As
  101.                long  as  the  alias  is  defined before the function is ex-
  102.                ecuted  (but  not  necessarily  before it is  defined), SKsh
  103.                will  execute the alias normally.   In  ksh,  on  the  other
  104.                hand, the alias  must  be  defined as such when the function
  105.                is defined, not when it is executed.
  106.  
  107.  
  108.             Assignment Syntax
  109.  
  110.                SKsh  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.  SKsh does not support any of these.
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.           SKSH Amiga Shell             Page 2         SKsh/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.   SKsh   provides  user  definable editing and two
  143.                functions  which  define editing styles similar to emacs and
  144.                vi.  A few of  the  commands, such as the ^r history search,
  145.                work slightly differently than they do in the Un*x ksh.
  146.  
  147.  
  148.             In-line parameter assignment
  149.  
  150.                ksh  permits variables to be assigned to while being used as
  151.                a parameter.  For example,
  152.  
  153.                  export COLUMNS=80
  154.  
  155.                SKsh does not  permit this.  You must perform the assignment
  156.                and export separately.
  157.  
  158.  
  159.             Job Control
  160.  
  161.                ksh has job control.  SKsh does not.
  162.  
  163.  
  164.             Path Separator Character
  165.  
  166.                ksh uses ':' as a  path  separator character.  Since the co-
  167.                lon is a  legal character in AmigaDos path names, a comma is
  168.                used instead.
  169.  
  170.  
  171.             Function Definition Syntax
  172.  
  173.                The  SKsh  function  definition  syntax using the 'function'
  174.                keyword is  compatible with ksh, but ksh also permits an al-
  175.                ternate syntax using 'function() { }' that SKsh does not.
  176.  
  177.  
  178.             Set vs. Options
  179.  
  180.                ksh  uses  the  'set'  keyword to  set  options to the shell
  181.                itself.  SKsh  uses  'set'  to  list  alias,  variables, and
  182.                functions.   SKsh  uses  the   'option' command to set shell
  183.                options.   These   options are, with only a few  exceptions,
  184.                different from their ksh counterparts.
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.           SKSH Amiga Shell             Page 3         SKsh/ksh Differences
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.             Scoping Rules
  206.  
  207.                The SKsh scoping rules are  different than the scoping rules
  208.                in  in  ksh.   Ksh  supports the 'typeset' keyword to create
  209.                local  variables; SKsh controls this with an option flag and
  210.                the  'local' command.  In addition, SKsh local variables can
  211.                be turned off entirely to emulate the sh scoping rules.
  212.  
  213.  
  214.             Builtin Commands
  215.  
  216.                SKsh  accomplishes many  things  with  builtin commands that
  217.                ksh  accomplishes with external binaries.  In addition, Unix
  218.                has  boatloads  more  of  these  commands than the Amiga and
  219.                SKsh  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 SKsh commands accept different pa-
  223.                rameters  than  either Unix counterparts with the same name.
  224.                Some of them  also  act  differently; for example, 'read' in
  225.                Unix  reads  a  single  parameter  separated by  IFS,  while
  226.                'read' in SKsh reads a whole line.
  227.  
  228.  
  229.             until...do...done statement
  230.  
  231.                SKsh does  not  support this construct.   I was not in a big
  232.                hurry  to  add  it,  since  it  is  simply a while..do..done
  233.                statement with the test automatically inverted.
  234.  
  235.  
  236.             Parameter Breaks
  237.  
  238.                SKsh  breaks  parameters in  different places than ksh.  For
  239.                example,  'foo'$foo  is  one  parameter in ksh, but  two  in
  240.                SKsh.  To make it one in SKsh, use double quotes around  the
  241.                whole expression: "foo$foo", or use $(concat "foo" "$foo").
  242.  
  243.  
  244.             Standard Error Redirection
  245.  
  246.                Under AmigaDos,  there  is  no  distinction between standard
  247.                output  and  standard error.  Thus, you cannot redirect them
  248.                independently in SKsh.
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.