home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / utility / cli / sksh017.lzh / doc / UserMan.doc < prev    next >
Encoding:
Text File  |  1991-05-04  |  94.6 KB  |  3,433 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                             User's Guide to
  17.  
  18.                                  SKsh
  19.  
  20.                     A ksh-like Shell for the Amiga
  21.  
  22.                               Version 1.7
  23.  
  24.  
  25.                          (Copyright) 1988-1991
  26.  
  27.                               Steve Koren
  28.  
  29.                               May 4, 1991
  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.        Table of Contents
  74.  
  75.         Introduction......................................3
  76.         Copyright Notice and Other Legal Stuff............4
  77.         A Brief History of Unix Shells....................5
  78.         SKsh Syntax.......................................6
  79.         Credits...........................................8
  80.         What SKsh is and is Not...........................9
  81.         The Rest of this Document.........................9
  82.         SKsh Basics: Executing Commands...................10
  83.         SKsh Basics: I/O Redirection......................11
  84.         SKsh Basics: Pipe Lines...........................12
  85.         SKsh Basics: Strings and Variables................13
  86.         SKsh Basics: Parameter Substitution...............15
  87.         SKsh Basics: Wildcards............................16
  88.         Using SKsh Aliases................................18
  89.         Using SKsh Functions..............................19
  90.         Function, Alias, Builtin Priority.................21
  91.         SKsh Command Substitution.........................22
  92.         Control Structures: if-then-elif-else-fi..........24
  93.         Control Structures: while-do-done.................25
  94.         Control Structures: for-do-done...................26
  95.         Control Structures: case-esac.....................27
  96.         Test Expressions..................................28
  97.         Sub-Shell Execution...............................30
  98.         File Name Mapping.................................31
  99.         SKsh Scripts......................................32
  100.         Command Line Editing and History..................33
  101.         Filename Completion...............................37
  102.         Advanced Topics: Using SKsh with ARexx............39
  103.         Advanced Topics: && and || operators..............41
  104.         Advanced Topics: [ ] Operator Used Independently..42
  105.         Advanced Topics: Variable Substitution Forms......43
  106.         Advanced Topics: Using Shared SKsh Modes..........44
  107.         Advanced Topics: Changing the SKsh Message File...46
  108.         Advanced Topics: Definable Keyboard Editing.......49
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.        SKsh Amiga Shell             Page 2                 User's Guide
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.        Introduction
  140.  
  141.      SKsh  (Amiga-shell)  is  a  shell  designed for the Amiga which
  142.      closely  duplicates  functionality  of  ksh or sh in Unix1.  It
  143.      is  designed  for  programmers and other  expert users who feel
  144.      limited  by  the  Amiga's  native shell environment.  SKsh pro-
  145.      vides a  very  powerful environment; however, it is not for ca-
  146.      sual workbench users who want a "point and click" interface.
  147.  
  148.      SKsh  provides a  large  number of features, some of which have
  149.      not been previously available in Amiga shells:
  150.  
  151.           *  Command substitution (using either  backtick  or  $(  )
  152.              notations)
  153.  
  154.           *  Shell functions with parameters
  155.  
  156.           *  Aliases
  157.  
  158.           *  Local variables, local functions, and local aliases
  159.  
  160.           *  Powerful control structures and tests
  161.  
  162.           *  emacs style line editing and history functions
  163.  
  164.           *  user definable keyboard editing commands
  165.  
  166.           *  I/O redirection and pipes
  167.  
  168.           *  A large variety of built-in commands
  169.  
  170.           *  Many external utilities such as "wc" and "grep"
  171.  
  172.           *  Resident command support
  173.  
  174.           *  ARexx support
  175.  
  176.           *  Unix style wildcards
  177.  
  178.           *  Unix filename conventions in AmigaDos (such as  ../file
  179.              or ~/file)
  180.  
  181.           *  Filename completion using <esc><esc> or tab
  182.  
  183.           *  Coexistence with scripts from other shells
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.        _____________________
  192.        1    Unix is a trademark of AT&T.
  193.  
  194.  
  195.        SKsh Amiga Shell             Page 3                 User's Guide
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.        Copyright Notice and Other Legal Stuff
  206.  
  207.      This  software  is  copyright 1989-1990 Steve Koren.  It is not
  208.      public  domain;  however, it is freely  distributable, provided
  209.      that it is not sold for  profit  without the written consent of
  210.      the author.  It may  be  included in compilations of public do-
  211.      main  software,  freely  distributable  software, and shareware
  212.      without  written  consent of  the  author provided that no more
  213.      than  $7.00  US  1989  dollars are charged for distribution and
  214.      disk handling overhead.
  215.  
  216.      This and all other  included documents and works are also copy-
  217.      right 1989-1990 Steve Koren, and  are  included in the terms of
  218.      the above paragraph.
  219.  
  220.      Any  code  included with this  software may be freely modified.
  221.      However,  further distribution of this modified software is re-
  222.      stricted to the  condition that a notice of the exact modifica-
  223.      tions be  clearly  included with the documentation.  The exist-
  224.      ing  documentation may not be  modified, only appended to.  The
  225.      sole  exception to this rule is that  the  documentation may be
  226.      translated to other languages and the original omitted.
  227.  
  228.      The  porting of this  software to other computers than the Com-
  229.      modore Amiga is permitted.
  230.  
  231.      This  software may be  uploaded to pay-for-use computer systems
  232.      such  as  GEnie or Compuserve (although obtaining it from there
  233.      is  of  questionable value, as it  is  available for free else-
  234.      where).    However, it may NOT be uploaded to any service which
  235.      claims  a  copyright or other right  over  the  software.   The
  236.      copyright is  exclusively mine.  (GEnie and Compuserve are used
  237.      here  as  examples;  if  they  violate the  copyright condition
  238.      above, SKsh may not be placed there).
  239.  
  240.      SKsh may NOT  be  included with magazine/disk packages or "disk
  241.      magazines"  whose  TOTAL  cost  exceeds $5 US 1989  dollars per
  242.      issue.  If you got SKsh from such as  source,  please  tell  me
  243.      its name  and  a  contact phone number.  SKsh is free software,
  244.      and if you paid for it, 1) you wasted your money, and 2)  some-
  245.      one else is profiting from my hard work without my permission.
  246.  
  247.      The  entire  SKsh  system must be distributed intact.  That is,
  248.      you may  receive these files as a zoo archive, a lharc archive,
  249.      or  unarchived on a Fish disk, but you  may  not  distribute an
  250.      incomplete subset of the system.
  251.  
  252.      The  author  of  this  software does not not officially support
  253.      it.   It  is   provided in the hope that it will be useful, but
  254.      since it is free,  no  guarantees of any kind are provided, and
  255.      you, the user, accept responsibility for its use.
  256.  
  257.  
  258.  
  259.  
  260.  
  261.        SKsh Amiga Shell             Page 4                 User's Guide
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.        A Brief History of Unix Shells
  272.  
  273.      Unix has, for a long time, had  two  standard shells.  csh pro-
  274.      vides a  programmable shell, and it is favored by some Unix us-
  275.      ers  because  it  also  provides limited mechanisms for history
  276.      and  command editing.  This editing is cumbersome, however, us-
  277.      ing notations like this:
  278.  
  279.            % ^echo^ls -l
  280.  
  281.      to edit lines.
  282.  
  283.      sh  provides a more powerful and intuitive programming environ-
  284.      ment  than  csh, so it is  preferred for writing scripts.  How-
  285.      ever, it lacks the editing and history facilities of csh.
  286.  
  287.      ksh is a newer Unix shell, and  is  fast  becoming the dominant
  288.      Unix environment.  It  provides much better editing and history
  289.      mechanisms than  csh, and a more powerful, but upwardly compat-
  290.      ible    programming  environment than sh.  This, it has the ad-
  291.      vantages of both shells.
  292.  
  293.      SKsh on the Amiga is  patterned closely after ksh, although ksh
  294.      provides a much more powerful environment than does SKsh.
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.        SKsh Amiga Shell             Page 5                 User's Guide
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.        SKsh Syntax
  338.  
  339.      If  you  are  familiar  with  ksh or  sh programming under Unix
  340.      (tm),  you  will  almost immediately become proficient at SKsh.
  341.      Although SKsh scripts are  not  compatible (except in some spe-
  342.      cific  cases)  with  those  of  sh or ksh, the syntax is nearly
  343.      identical, and many  of  the  same  commands are present.  SKsh
  344.      operation will  be  discussed in much greater detail later, but
  345.      some  examples are presented here, mainly for those who are al-
  346.      ready  familiar with Unix shells.  If  you  do  not  understand
  347.      these examples, this section can be safely ignored.
  348.  
  349.         A  simple  command  is  a  single  external function, alias,
  350.         builtin  command, or  shell  function.   For  example, "echo
  351.         foo" is a simple command, as is "a = 42" or "preferences".
  352.  
  353.         A  control  structure is a  method  of  directing execution.
  354.         Control  structures can  contain simple commands, other con-
  355.         trol structures, pipe-lines, or sub-shells.
  356.  
  357.              if [ $a -gt 0 ]
  358.              then
  359.                  while [ $a -lt 10 ]
  360.                  do
  361.                     echo "A = $a"
  362.                     inc a
  363.                  done
  364.              fi
  365.  
  366.         A  pipeline is a sequence of simple commands, control struc-
  367.         tures or sub-shells  separated by pipe symbols.  A pipe sym-
  368.         bol is a  vertical bar ('|').  For example, the following is
  369.         a pipeline:
  370.  
  371.           for param in "these" are 'parameters' $boo
  372.           do
  373.              echo $param
  374.           done | wc
  375.  
  376.         (notice  the  pipe  symbol  in  between the for-loop and the
  377.         word  count  command).  The  input or output from a pipe can
  378.         also be re-directed to or from a file.
  379.  
  380.         A  subshell is a method of grouping commands, control struc-
  381.         tures, pipes, or other sub-shells.   Sub-shells  are  delim-
  382.         ited by either parentheses:
  383.  
  384.           (echo foo; echo bar)
  385.  
  386.         or curly-braces:
  387.  
  388.           { which emacs; whence emacs }
  389.  
  390.         Sub-shells  have  certain  specific uses, and the two  forms
  391.  
  392.  
  393.        SKsh Amiga Shell             Page 6                 User's Guide
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.         above  differ in  their  behavior; this will be explained in
  404.         greater detail later.
  405.  
  406.         Command  substitution is a method  for  including the output
  407.         of  a  command as if it was  typed  into  the  command line.
  408.         Again, this will  be  explained in greater detail later, but
  409.         here are  some  examples using both the backtick (`) and the
  410.         $( ) syntax:
  411.  
  412.           a=`basename foo:bar/not/file`
  413.  
  414.         or
  415.  
  416.           echo $(expr length $(date -y))
  417.  
  418.         A  shell  function is  similar to a script, but it is stored
  419.         in the shell  itself instead of a file.  Thus, it can be ac-
  420.         cessed much faster than a script.  Here is  a  sample  func-
  421.         tion definition:
  422.  
  423.           function param_count {
  424.              echo "$# parameters were passed to this function,"
  425.              echo "the second of which is $2"
  426.           }
  427.  
  428.         Functions  can  contain  local variables, local aliases, and
  429.         even  local  functions, as well as  any  combination of com-
  430.         mands  and  control  structures.    Functions can call other
  431.         functions and scripts, as well.
  432.  
  433.         An  alias  is  simply a way to save typing effort.  An alias
  434.         can be used to take the place of  a  command and some of its
  435.         parameters so that  the  command is easier to type.  For ex-
  436.         ample,
  437.  
  438.           alias '!' = 'history -e'
  439.  
  440.         There are  other  features as well that will become apparent
  441.         later.
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.        SKsh Amiga Shell             Page 7                 User's Guide
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.        Credits
  471.  
  472.      SKsh was developed on and for the Commodore Amiga.
  473.  
  474.      SKsh  was  implemented  and  debugged  entirely with  Lattice C
  475.      5.05.  Aside from a few bugs  that  cause  incorrect code to be
  476.      generated at times, its a  reasonably solid compiler.  It has a
  477.      great debugger, too.
  478.  
  479.      SKsh was written and is copyrighted by Steve Koren.
  480.  
  481.      This manual and the  other  included documents were written and
  482.      are copyrighted by Steve Koren.
  483.  
  484.      This manual  was  written using excellence! 2.0 by MSS.  It did
  485.      all the cool stuff like the table of contents and index.
  486.  
  487.      SKsh is freely distributable.
  488.  
  489.      The SKsh  parser  was  created using Amiga YACC.  This yacc was
  490.      ported to the Amiga by  Bill  Lee,  and  worked  great  once  I
  491.      recompiled it with larger tables to handle  the  SKsh  grammar.
  492.      I had  expected to have problems with a micro based yacc, but I
  493.      had none at all.
  494.  
  495.      Until  SKsh  was  usable, I used Matt  Dillon's  shell  version
  496.      3.01A  during SKsh development.  I like that shell  far  better
  497.      than  the  normal  AmigaDos  environment.   It  provides "real"
  498.      wildcards, and many other neat things  the  normal AmigaDos en-
  499.      vironment does not.
  500.  
  501.      A bunch of people on Usenet  and  at  the  Cleveland Area Amiga
  502.      Users's  Group  have  my  appreciation  for  putting up with my
  503.      silly  questions  about  invoking  programs on the Amiga (which
  504.      turns out, unfortunately, not to be a trivial task).
  505.  
  506.      SKsh  uses  ARP  for  command execution.  There  was  no  other
  507.      simple way to do it.
  508.  
  509.      I would  like  to  thank  everyone who made suggestions and re-
  510.      ported bugs.  These people are too  numerous  to  mention indi-
  511.      vidually,  but  nonetheless have  contributed to SKsh in an im-
  512.      portant way.
  513.  
  514.      I would also like to thank Fred Fish (who  maintains a compila-
  515.      tion of  freely  distributable Amiga software) and Tad Guy (who
  516.      is  the  moderator of the  comp.binaries.amiga  usenet  group).
  517.      Both  work  very  hard  to  distribute free Amiga software, and
  518.      SKsh benefits greatly from this wider and faster distribution.
  519.  
  520.      ARexx is a commercial program by William S. Hawes.
  521.  
  522.  
  523.  
  524.  
  525.        SKsh Amiga Shell             Page 8                 User's Guide
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.        What SKsh is and is Not
  536.  
  537.      SKsh  is  a  powerful  alternative to the normal AmigaDos shell
  538.      environment.  This power comes at a price,  however.   SKsh  is
  539.      not a tiny program.  SKsh is  currently about 75 K bytes; small
  540.      by Unix standards but quite large for AmigaDos.
  541.  
  542.      SKsh  provides a  very  similar environment to that found under
  543.      the two Unix shells  mentioned above.  It does not claim or at-
  544.      tempt  to  provide  an  identical  environment.   Some   simple
  545.      scripts  will  run  under SKsh or ksh, but this fact should not
  546.      be  depended on.  In  many  cases,  ksh  provides features that
  547.      SKsh does not.  In some cases, SKsh  provides features that ksh
  548.      does not.  SKsh is,  however, not a general purpose programming
  549.      language  -  it  is  tailored to writing scripts that use other
  550.      programs and AmigaDos facilities.
  551.  
  552.      SKsh is not a speed daemon.  It  would  have  been  possible to
  553.      write a much  faster  programmable shell; however, it would not
  554.      have  provided  the  ksh-like  environment that SKsh does.  The
  555.      SKsh  script  language is adequately fast for simple tasks, but
  556.      it is not suitable for complex calculations or algorithms.
  557.  
  558.      SKsh  is  freely  distributable software.   It  is  not  public
  559.      domain.  No one else may sell  SKsh  without my written permis-
  560.      sion,  except in  the  cases  detailed in the copyright notice.
  561.      You  are,  however,  encouraged to distribute SKsh as widely as
  562.      possible.  It  is  completely free; however, with my other free
  563.      software  package (QRT, a ray tracer) some  people  sent  money
  564.      anyway.  Any money I do  receive from SKsh will be used for re-
  565.      pair,  maintenance, and upgrade of my 2000, and to purchase up-
  566.      grades to Lattice C and other Amiga software.
  567.  
  568.  
  569.        The Rest of this Document...
  570.  
  571.      The  rest  of  this  document is an intermediate level tutorial
  572.      for  using SKsh.  It assumes that you are familiar with the ba-
  573.      sic  concept and  operation of a command interface, such as the
  574.      AmigaDos CLI.   If  you  are  already a user of sh or ksh under
  575.      Unix,  you  will  probably be able to go through this  document
  576.      very quickly.  I do  recommend that you read it, though, to see
  577.      what SKsh does and does not do, and  to  see  what  differences
  578.      there are between SKsh and the Unix shells.
  579.  
  580.      The SKsh  reference manual explains each command in greater de-
  581.      tail,  although more  concisely.   This  document does not even
  582.      come close to  covering every SKsh command.  It is mean to give
  583.      you  an  understanding of the SKsh environment, so that you can
  584.      examine  the  reference  manual  for  information  on  specific
  585.      commands.
  586.  
  587.  
  588.  
  589.  
  590.  
  591.        SKsh Amiga Shell             Page 9                 User's Guide
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.        SKsh Basics: Executing Commands
  602.  
  603.      SKsh can, at the most simple level, be used like  the  AmigaDos
  604.      shell.   SKsh  will  display a prompt; exactly what this prompt
  605.      says can be  changed  in  a  number of ways, but by default the
  606.      prompt  contains  the  current  working  directory, enclosed in
  607.      square  brackets,  followed by  a  colon, and highlighted, like
  608.      this:
  609.  
  610.         [dh0:usr/graphics]: _
  611.  
  612.      After you see this prompt, you may type commands.  It does  not
  613.      matter if these commands are external or internal to SKsh.
  614.  
  615.      Multiple  commands on may be placed on a line if separated by a 
  616.      semicolon (';').  (Note:  a  semicolon does not always separate
  617.      commands.  For  example, if the semicolon is quoted, it becomes
  618.      part of a string).  In  addition, any text after a '#' is taken
  619.      to be a comment.
  620.  
  621.      Previous  commands  may  be  recalled and edited for reuse.  In
  622.      addition, they may be searched for in  the  history list.  This
  623.      will  be  explained in more detail later; for those who are fa-
  624.      miliar with the  'emacs'  editor from FSF, SKsh duplicates some
  625.      of those keybindings.  As will be  explained later, SKsh is ca-
  626.      pable  of  using  custom keymaps so that other  editors such as
  627.      'vi' may be emulated as well.
  628.  
  629.      In  SKsh,  pressing control followed by 'c' (^c) will generally
  630.      abort  whatever SKsh  is  currently doing and return you to the
  631.      SKsh prompt.  For  example, if you type 'sleep 6000', SKsh will
  632.      wait for a very long time  before returning to the prompt.  You
  633.      can press ^c to abort this  command.   However, if an external,
  634.      non-SKsh  command  is  executing,  that  command may or may not
  635.      listen to ^c.
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.        SKsh Amiga Shell            Page 10                 User's Guide
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.        SKsh Basics: I/O Redirection
  668.  
  669.      The  input to or  output from commands may be redirected.  This
  670.      is accomplished by using Unix style operators:
  671.  
  672.         <  = redirect input
  673.         >  = redirect output
  674.         >> = redirect output, but append
  675.  
  676.      Any  type  of  command or statement may be redirected.  For ex-
  677.      ample, the following are all equally valid:
  678.  
  679.         c:status > outfile
  680.  
  681.         sksh_script < infile >outfile
  682.  
  683.         while read in_line
  684.         do
  685.            echo "Line was: $in_line"
  686.         done < input_file
  687.  
  688.         { echo; version; echo } >> out_file
  689.  
  690.      Note in the last  two  cases  that  SKsh  statements as well as
  691.      simple  commands can use I/O redirection.  This is  a  powerful
  692.      feature  provided by Unix shells, but not,  until now, by Amiga
  693.      shells.
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.        SKsh Amiga Shell            Page 11                 User's Guide
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.        SKsh Basics: Pipe Lines
  734.  
  735.      A  pipeline  is  simply  a  series of statements separated by a
  736.      pipe symbol ('|').  For example,
  737.  
  738.         [dh0:]: echo "This is a pipe-line" | wc
  739.  
  740.      There can be any  number of newlines after the pipe-symbol, but
  741.      not   before  it  since  a  newline  typically  ends  a  simple
  742.      statement.  Thus, this is legal:
  743.  
  744.         [dh0:]: cat my_file.txt |
  745.                 head -20 |
  746.                 xd
  747.  
  748.      but this is not:
  749.  
  750.         [dh0:]: cat my_file.txt
  751.                 | head -20
  752.                 | xd
  753.  
  754.      since the newline after the 'cat...' terminates the command.
  755.  
  756.      Pipes  are  not  limited to simple commands.  They may be  used
  757.      with any SKsh statement:
  758.  
  759.         [dh0:]: for a in a b c d e
  760.         >      do
  761.         >        echo "a = $a"
  762.         >      done | { read aa; read bb }
  763.         [dh0:]: echo $aa
  764.              a = a
  765.  
  766.      SKsh  was  written  to  operate with the AmigaDos pipe: device,
  767.      with  each  branch  of  the  pipe-line  executing as a separate
  768.      process.    However,  some  limitations  in  the  way  AmigaDos
  769.      handles  processes made a simple thing  very  complex.   There-
  770.      fore,  the  first  release of SKsh uses  temporary files in the
  771.      pipe-line  instead of true inter-process pipes  using the pipe:
  772.      device.    Temporary file pipes are not nearly as useful as in-
  773.      terprocess pipes; they are slower, and are  limited by the free
  774.      space  on  the  device used to hold the files.  However, at the
  775.      moment,  the  capability I need to implement interprocess pipes
  776.      is  simply not there in  a  usable manner.  If the needed capa-
  777.      bility ever shows up on the Amiga, SKsh is  written to take ad-
  778.      vantage of it, and the code change to do this will  be  only  a
  779.      few  lines.    Interprocess  pipes  using the pipe:  device are
  780.      still  usable in the  normal manner using multiple CLI windows;
  781.      it is just not as convenient as the SKsh '|' pipe notation.
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.        SKsh Amiga Shell            Page 12                 User's Guide
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.        SKsh Basics: Strings and Variables
  800.  
  801.      Strings  and  variables are  basic to the operation of SKsh.  A 
  802.      string is  simply a sequence of non-special characters, option-
  803.      ally  surrounded by single or double quotes.  For example, this
  804.      is a string:
  805.  
  806.         howdy
  807.  
  808.      A string which  contains white space or special characters must
  809.      be  quoted.   The  most  common way to quote a string is to use 
  810.      double quotes:
  811.  
  812.         "this string contains spaces and < special | symbols"
  813.  
  814.         "this string
  815.          contains several
  816.          newline characters"
  817.  
  818.      Strings can  also  be  surrounded by single quotes.  This has a
  819.      slightly  different  meaning;  see  the  section  on  variables
  820.      below.
  821.  
  822.      A  string  delimited by doubles quotes  can  contain the double
  823.      quote character itself by prefixing it with a backslash:
  824.  
  825.         "this string contains \" a double quote"
  826.  
  827.      Similarly, a single quoted  string  can  contain a single quote
  828.      if  prefixed by a  backslash.   There  are  also  several other
  829.      backslash escapes possible:
  830.  
  831.         \n   - newline character
  832.         \t   - tab character
  833.         \f   - form feed character
  834.         \\   - backslash character itself
  835.         \^   - the caret character
  836.  
  837.      Any  control character can be included in a string by prefixing
  838.      it with a caret (^).  For example, "^[" is escape.
  839.  
  840.      A  shell  variable  in  SKsh  is  simply  a  storage place  for
  841.      strings.   Any   number of variables can be created.  Variables
  842.      can be assigned values using the assignment operator:
  843.  
  844.         [dh0:]: my_var="contents of my_var variable"
  845.         [dh0:]: my_var2  = "more stuff"
  846.  
  847.      Note  that  the  second line above, with spaces around the  as-
  848.      signment  operator,  is  legal in SKsh, but not  in  sh or ksh.
  849.      The  SKsh  assignment  operator is upwardly compatible with the
  850.      Unix shells.
  851.  
  852.      Variables can be  retrieved by prefixing the variable name with
  853.  
  854.  
  855.        SKsh Amiga Shell            Page 13                 User's Guide
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.      a '$'.  (In the  examples below the results of the commands are
  866.      indented for clarity).
  867.  
  868.         [dh0:]: echo $my_var
  869.              contents of my_var variable
  870.         [dh0:]: echo $my_var2
  871.              more stuff
  872.  
  873.      ("echo"  is  a  command  that  simply displays its parameters).
  874.      Variables  can  also  be   expanded  inside  of  double  quoted
  875.      strings:
  876.  
  877.         [dh0:]: echo "my_var = $my_var"
  878.              my_var = contents of my_var variable
  879.  
  880.      However,  variables  are  not  expanded inside of single quoted
  881.      strings.  For example,
  882.  
  883.         [dh0:]: echo '$my_var'
  884.              $my_var
  885.  
  886.      This  would  not  display the  contents of the variable my_var,
  887.      but rather  would  display the actual string $my_var, including
  888.      the '$' symbol.
  889.  
  890.      Variables  may  contain nearly any amount of information.  They
  891.      typically are used  to  contain only small strings and numbers,
  892.      but if you wished you could store a whole file  in  a  variable
  893.      by saying:
  894.  
  895.         [dh0:]: big_var = $(cat my_file.txt)
  896.  
  897.      (the  $(  )  notation is  simply a way to execute a command and
  898.      use  the  output of the command in another command.  It will be
  899.      discussed in  more  detail later.  The above command is equiva-
  900.      lent to big_var = `cat my_file`, which may be more  familiar to
  901.      sh users, but the first example above is recommended).
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.        SKsh Amiga Shell            Page 14                 User's Guide
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.        SKsh Basics: Parameter Substitution
  932.  
  933.      SKsh  normally  eliminates  white  space  (blanks, newlines and 
  934.      tabs)  from  between  parameters to commands.  For example, no-
  935.      tice the spacing in the following command and response:
  936.  
  937.         [dh0:]: echo notice    the       spacing   here
  938.              notice the spacing here
  939.  
  940.      If  you  wish  to  maintain the spacing above, you must put the
  941.      text  in  either a single or double quoted string, which causes
  942.      it to be treated as a single parameter:
  943.  
  944.         [dh0:]: echo 'notice    this   spacing'
  945.              notice    this   spacing
  946.  
  947.      Even  if  the  string  echoed comes from  a  variable, the same
  948.      elimination of white space takes place:
  949.  
  950.         [dh0:]: a='some    text'
  951.         [dh0:]: echo $a
  952.              some text
  953.  
  954.      If  you  wish  to  preserve  the  spacing, you must enclose the
  955.      variable in double quotes  (remember, variables are expanded in
  956.      double but not single quotes):
  957.  
  958.         [dh0:]: a='some    text'
  959.         [dh0:]: echo "$a"
  960.              some    text
  961.  
  962.      (Note  for  advanced  users: this action is actually controlled
  963.      by a variable called the internal field separator, or IFS.)
  964.  
  965.      Internal SKsh  commands can have any number of parameters, (un-
  966.      til you run out of  memory).   External commands are limited by
  967.      the  AmigaDos  command  interpreter, which does not accept com-
  968.      mands longer than 256 characters in version 1.3.
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.        SKsh Amiga Shell            Page 15                 User's Guide
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.        SKsh Basics: Wildcards
  998.  
  999.      SKsh uses  Unix  style  wildcard  patterns to match files.  The
  1000.      following characters have special meaning:
  1001.  
  1002.         *    - matches any number of characters, including zero
  1003.         ?    - matches exactly one character
  1004.         [ ]  - characters which enclose a character class
  1005.         !    - negate the pattern
  1006.         \    - turns off magic properties of following character
  1007.  
  1008.      Since  wildcards  are  expanded by SKsh, and not by the command
  1009.      itself as in AmigaDos, they  may  be  used  with  any command -
  1010.      even  a  command such as 'echo' which  does  not  normally deal
  1011.      with files (try echo *).
  1012.  
  1013.      Here  are  some  examples  using the  first  two  special types
  1014.      above:
  1015.  
  1016.         a*f       matches 'af', 'abf', 'aazzzewerf', etc.
  1017.         a?f       matches 'abf', 'acf', but not 'af' or 'aaaf'
  1018.  
  1019.      The  square  brackets  above  are  used  to  define a character
  1020.      class.   A   character class is  simply way to specify an exact 
  1021.      set of  characters.  Character classes may contain either a se-
  1022.      ries of  enumerated characters, a range of characters, or a ne-
  1023.      gation of any of the above.  For example,
  1024.  
  1025.  
  1026.         [abcz]    matches the character a, b, c, or z.
  1027.         [a-cv-z]  matches either a, b, c, v, w, y, x, or z.
  1028.         [!a-d]    matches any character except a, b, c, or d.
  1029.  
  1030.      Character classes may be combined with the * and ? wildcards:
  1031.  
  1032.         [a-c]*.c  matches  any  file  starting with a, b, or  c  and
  1033.                   ending with '.c'
  1034.  
  1035.      Wildcards  are  only  expended  as  normal parameters; that is,
  1036.      outside of quoted strings of any  sort.   Wildcards  also  have
  1037.      certain  other  uses  in  SKsh  besides matching files (for ex-
  1038.      ample, see the 'match' or 'set' commands).
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.        SKsh Amiga Shell            Page 16                 User's Guide
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.      Wildcards do not have to be used in only  the  filename  compo-
  1064.      nent of a  path.   For  example, all of the following are valid
  1065.      wildcard patterns:
  1066.  
  1067.         sys:*/Format
  1068.         sys:System/Fo*
  1069.         mydir/*/*.c
  1070.         *.[hc]
  1071.  
  1072.      Wildcards are not by  default case sensitive, although this may
  1073.      be changed with the options command.
  1074.  
  1075.      A backslash will turn off the  magic  properties of the follow-
  1076.      ing character.  For example,
  1077.  
  1078.         [dh0:]: echo test\*ing
  1079.                   test*ing
  1080.  
  1081.      (See also: File name mapping)
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.        SKsh Amiga Shell            Page 17                 User's Guide
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.        Using SKsh Aliases
  1130.  
  1131.      An  'alias' in  SKsh  is  simply a way to save typing time.  An
  1132.      alias can  stand  for  any  series of characters.  For example,
  1133.      perhaps  you  enjoy seeing the version number of SKsh.  You en-
  1134.      joy it so much, in fact,  that  you  tire  of  typing 'version'
  1135.      over and over.  You can  define an alias, called 'v', that sim-
  1136.      ply stands for the 'version' command:
  1137.  
  1138.         [dh0:]: alias v=version
  1139.         [dh0:]: v
  1140.              SKsh Version 1.5, Copyright 1989, 1990 Steve Koren
  1141.  
  1142.      You can also include parameters  after  the  alias  call.   For
  1143.      example:
  1144.  
  1145.         [dh0:]: v -d
  1146.              13:09:06 Mar 17 1990
  1147.  
  1148.      The  alias  command only looks at  one  parameter after the '='
  1149.      sign, so  to  include parameters in the alias, you must enclose
  1150.      the alias definition in quotes:
  1151.  
  1152.         [dh0:]: alias v='version -d'
  1153.         [dh0:]: v
  1154.              13:09:06 Mar 17 1990
  1155.  
  1156.      To  obtain  a  list of aliases, simply use the alias command by
  1157.      itself:
  1158.  
  1159.         [dh0:]: alias
  1160.              (big list of aliases)
  1161.  
  1162.      I left out  the  list  of  aliases  above,  because there are a
  1163.      large  number  supplied by SKsh itself.  One of these  supplied
  1164.      aliases is  the  unalias command.  To find out what the defini-
  1165.      tion of unalias is:
  1166.  
  1167.         [dh0:]: alias unalias
  1168.              unalias      = unset -a
  1169.  
  1170.      So,  the  unalias  command  simply runs the command 'unset -a'.
  1171.      Unalias  is  provided as a built in alias, however, since it is
  1172.      easier  to  remember than unset -a.  Unalias removes any number
  1173.      of alias definitions:
  1174.  
  1175.         [dh0:]: unalias v foo bar
  1176.  
  1177.      The above  line  would  remove the alias definitions of v, foo,
  1178.      and bar.
  1179.  
  1180.      Note that  alias  commands may be used just like any other com-
  1181.      mand, in scripts, functions, or substitution statements.
  1182.  
  1183.  
  1184.  
  1185.        SKsh Amiga Shell            Page 18                 User's Guide
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.        Using SKsh Functions
  1196.  
  1197.      While  aliases  are  limited to simple text  substitution uses,
  1198.      functions are vastly  more  powerful.   Functions provide a way
  1199.      to  store  SKsh  programs  within  SKsh  itself instead of in a
  1200.      file.   Here  is  an   example function that SKsh loads when it
  1201.      starts up.  Don't worry if you  don't  understand everything in
  1202.      the  function  definition; it  will  be  explained later in the
  1203.      programming sections.  For now, just  notice that functions can
  1204.      contain  any  SKsh  statements,  and  are  delimited  by  curly
  1205.      braces:
  1206.  
  1207.         function path {   # set or examine path
  1208.              local comp;
  1209.  
  1210.              if [ $# -eq 0 ]
  1211.              then
  1212.                echo "$PATH"
  1213.              elif [ "$1" = '-add' -o "$1" = 'add' ]
  1214.              then
  1215.                shift
  1216.  
  1217.                for comp in $* do
  1218.                   if [ $( expr index "$PATH," "$comp," ) -eq 0 ]
  1219.                   then
  1220.                     PATH = "$PATH,$comp"
  1221.                   fi
  1222.                done
  1223.              else
  1224.                PATH="$1"
  1225.              fi
  1226.  
  1227.              export -l PATH
  1228.         }
  1229.  
  1230.      That  function is  one  that  defines a "path" command in SKsh.
  1231.      Functions may be used like any other command.  You do not  even
  1232.      have to know that they are functions.   For  example, the above
  1233.      command, with no  parameters, simply prints the path.  This can
  1234.      be output to a file, a follows:
  1235.  
  1236.         [dh0:]: path > my_file
  1237.  
  1238.      The path  function could also be used in other functions.  This
  1239.      provides  a  very  powerful  mechanism for  extending SKsh.  It
  1240.      will  be  particularly  interesting for floppy users who do not
  1241.      want to wait for slow script files.
  1242.  
  1243.      When  SKsh  functions  are  executed,  several important things
  1244.      happen.   All  variables, functions, and aliases defined inside
  1245.      the  function are  local to that function (although this behav-
  1246.      ior  is  changeable in  several ways - see the option command).
  1247.      Hence:
  1248.  
  1249.  
  1250.  
  1251.        SKsh Amiga Shell            Page 19                 User's Guide
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.         function outer {
  1262.            function inner {
  1263.               echo "my first parameter is $1"
  1264.            }
  1265.            inner $1
  1266.         }
  1267.  
  1268.      The  function  named  'inner' can only be used within the func-
  1269.      tion  named  'outer'.   You  will   notice also that a variable
  1270.      called $1 is  referenced, but not set.  There are several vari-
  1271.      ables  that  are  automatically set by SKsh when a function (or
  1272.      script) is invoked.  The  most  useful are $0, $1, $2, $3, etc.
  1273.      They are set to the  parameters passed into the function.  Note
  1274.      that $0 is set to the function name itself:
  1275.  
  1276.         [dh0:]: function test1 {
  1277.         >    echo "0 = $0, 1 = $1, 2 = $2"
  1278.         > }
  1279.  
  1280.         [dh0:]: test1 foo bar
  1281.              0 = test1, 1= foo, 2 = bar
  1282.  
  1283.      Also note the ">" marks to the left of the 2nd  and  3rd  lines
  1284.      of the function.  They  are  the  secondary SKsh prompt string,
  1285.      used when it expects more input.  You shouldn't type them.
  1286.  
  1287.      SKsh also  sets  the  variable '$#' to the number of parameters
  1288.      passed into the function:
  1289.  
  1290.         [dh0:]: function countp { echo "Number = $#" }
  1291.         [dh0:]: countp "this is all one" another param
  1292.              Number = 3
  1293.  
  1294.      The  variable  '$*' is set to  the  entire parameter list.  For
  1295.      example:
  1296.  
  1297.  
  1298.         [dh0:]: function pparams { echo "Args = $*" }
  1299.         [dh0:]: pparams foo bar not
  1300.              Args = foo bar not
  1301.  
  1302.      These  standard variables can be modified with the 'shift' com-
  1303.      mand - see the documentation on that command for details.
  1304.  
  1305.      Any  functions or aliases used within  a  function will operate
  1306.      correctly even if they  are  defined after the function itself.
  1307.      (That is,  they  are  bound  dynamically at run-time).  This is
  1308.      different than the ksh behavior.
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.        SKsh Amiga Shell            Page 20                 User's Guide
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.        Function, Alias, Builtin Priority
  1328.  
  1329.      In SKsh, you can  define a function or alias that overrides the
  1330.      definition  of  a  an  SKsh  builtin  command (such as the echo
  1331.      statement).   SKsh  will  evaluate a function definition before
  1332.      an alias with the same  name,  and  an  alias  before a builtin
  1333.      with the same name.  Thus, you  can  redefine the internal sksh
  1334.      commands.
  1335.  
  1336.      SKsh  still  provides  a  mechanism to  access the builtin com-
  1337.      mands, even though you  might  have  redefined them.  The force
  1338.      keyword can be used to  force the execution of a command as ei-
  1339.      ther a  function, an alias, or a builtin.  For example, say you
  1340.      have  redefined the sksh  date command with a function, as fol-
  1341.      lows:
  1342.  
  1343.         [dh0:]: function date {
  1344.         >    echo 'The date command is not available today.'
  1345.         >    }
  1346.  
  1347.      Any  future calls to the  date  command will have the following
  1348.      result:
  1349.  
  1350.         [dh0:]: date
  1351.              The date command is not available today.
  1352.  
  1353.      Suppose,  however, that you  really did wish to access the date
  1354.      builtin  command, and not your function.  Use the force keyword
  1355.      with the -b options (for force execution as a builtin):
  1356.  
  1357.         [dh0:]: force -b date
  1358.              Sat Oct 14 11:13:27 1989
  1359.  
  1360.      This  can  be  particularly  useful when you wish  to  use  the
  1361.      original date  command inside of your own.  Perhaps you wish to
  1362.      define a  date  command which prints "The year is:" followed by
  1363.      the current year:
  1364.  
  1365.         [dh0:]: function date {
  1366.         >    echo -n 'The year is: '; force -b date -y
  1367.         >    }
  1368.         [dh0:]: date
  1369.              The years is: 1989
  1370.  
  1371.      In this case, the force  -b  command must be used to access the
  1372.      builtin date command.  If it was left out, the new  date  func-
  1373.      tion would be  used  instead, calling itself recursively.  SKsh
  1374.      would  eventually detect this situation and issue an error mes-
  1375.      sage, but it is not what the command was intended to do.
  1376.  
  1377.      The  force  keyword also accepts -f and -a parameters, to force
  1378.      execution as a function or alias.
  1379.  
  1380.  
  1381.  
  1382.  
  1383.        SKsh Amiga Shell            Page 21                 User's Guide
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.        SKsh Command Substitution
  1394.  
  1395.      SKsh  provides several mechanisms for capturing the output of a
  1396.      statement  for  subsequent use.  The preferred method is to use
  1397.      the following syntax:
  1398.  
  1399.         $(command)
  1400.  
  1401.      SKsh  will  insert the output of the command as if it was typed
  1402.      in  the  SKsh  command  line.    Consider an example.  The sksh
  1403.      function 'basename' prints the file name part of a  path  name.
  1404.      For example,
  1405.  
  1406.         [dh0:]: basename sys:path/to/my/file
  1407.              file
  1408.  
  1409.      Now,  suppose you wish to obtain the file part of a path string
  1410.      for use in an sksh function.   Normally the 'basename' function
  1411.      copies the data to the screen.   You  want  to  have  it  in  a
  1412.      variable.  If the path you're  interested in is in the variable
  1413.      my_path:
  1414.  
  1415.         [dh0:]: bn = $(basename $my_path)
  1416.  
  1417.      The  variable 'bn'  will  contain the desired information.  Pa-
  1418.      rameter  substitution may be nested.  For  example, perhaps you
  1419.      wish to  obtain the length in characters of the file portion of
  1420.      the path name:
  1421.  
  1422.         [dh0:]: len = $(expr length $(basename $my_path) )
  1423.  
  1424.      The   alternative   syntax   for   command  substitution  uses  
  1425.      backticks:
  1426.  
  1427.         [dh0:]: len = `basename $my_path`
  1428.  
  1429.      However,  the  first  notation  is  preferred for  a  number of
  1430.      reasons.    Using the backtick  notation, SKsh reads the entire
  1431.      substitution  command as one  token, or set of characters.  To-
  1432.      kens in SKsh are  limited by the parser to 1024 characters (al-
  1433.      though strings  and  variables can be of any length).  The par-
  1434.      enthetical  notation  for  command substitution has no restric-
  1435.      tions on the length  of  the  command enclosed - it could be an
  1436.      entire  sksh  program.   Also,  the   parenthetical notation is
  1437.      faster than the backtick notation.
  1438.  
  1439.      You  will  discover that  command substitution is a very useful
  1440.      thing to have around.  One of the more  common uses is the fol-
  1441.      lowing:
  1442.  
  1443.         [dh0:]: my_program $(which abc)
  1444.  
  1445.      Here,  my_program is a program which uses abc in some way (per-
  1446.      haps  executes it  or  edits it).  'abc' is known to be in your
  1447.  
  1448.  
  1449.        SKsh Amiga Shell            Page 22                 User's Guide
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.      SKsh path, but  my_program does not know about SKsh paths.  The 
  1460.      which  function in SKsh prints the full path name of a file  in
  1461.      the search path, so the above  command saves you from having to
  1462.      remember and type the full path.
  1463.  
  1464.      Command  substitution works with any SKsh statement.   For  ex-
  1465.      ample:
  1466.  
  1467.         [dh0:]: a = $( for a in a b c
  1468.         >              do
  1469.         >                 echo "a: $a"
  1470.         >              done )
  1471.  
  1472.         [dh0:]: echo "$a"
  1473.              a: a
  1474.              a: b
  1475.              a: c
  1476.  
  1477.      Note that  the  same  variable was used both inside and outside
  1478.      the  command substitution.  This is  ok,  since  the  statement
  1479.      list  inside  the  command  substitution  marks  is  completely
  1480.      evaluated before the assignment is made.
  1481.  
  1482.      Command  substitution can also be used with  external commands.
  1483.      Since  external  binaries do  not  support command substitution
  1484.      directly, SKsh  stores  the  results in a temporary file in the
  1485.      't:'  directory.   When   finished, SKsh  deletes the temporary
  1486.      file.  't:' should be  assigned to a fast device, such as a ram
  1487.      disk.    Actually, a subdirectory on the ram disk is  best,  so
  1488.      that SKsh's temporary files won't normally be seen.
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.        SKsh Amiga Shell            Page 23                 User's Guide
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.        Control Structures: if-then-elif-else-fi
  1526.  
  1527.      SKsh  provides  a  set  of  control  structures  for  directing
  1528.      execution.  The most  common of these is the if-then-elif-else-
  1529.      fi statement.   It  has  several forms, but the most common are
  1530.      these:
  1531.  
  1532.         if [ test expression ]
  1533.         then
  1534.            statement
  1535.            list
  1536.         fi
  1537.  
  1538.      The  test  expression  is  evaluated (more on test  expressions
  1539.      later), and if  it  is  true,  the  statement list is executed.
  1540.      The if statement can have an else part:
  1541.  
  1542.         if [ expression ]
  1543.         then
  1544.            statement list
  1545.         else
  1546.            statement list
  1547.         fi
  1548.  
  1549.      It can also have any number of else-if expressions:
  1550.  
  1551.         if [ expression ]
  1552.         then
  1553.            stmt_list
  1554.         elif [ expression ]
  1555.            stmt_list
  1556.         else
  1557.            stmt_list
  1558.         fi
  1559.  
  1560.      Any valid SKsh statement list can be used inside the if:
  1561.  
  1562.         if [ $a -lt 10 ]
  1563.         then
  1564.            a = 20
  1565.            echo "a WAS less than ten, but now it's $a"
  1566.         fi
  1567.  
  1568.      An  alternative form of  the  if  statement can be used to test
  1569.      the return code from a command.  For example,
  1570.  
  1571.         if cmp -s file1 file2
  1572.         then
  1573.            echo 'Files are the same'
  1574.         fi
  1575.  
  1576.      If  the  command  following the  if  keyword returns TRUE (or a
  1577.      zero  return code), the if  statement proceeds as if an expres-
  1578.      sion returned true.
  1579.  
  1580.  
  1581.        SKsh Amiga Shell            Page 24                 User's Guide
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.        Control Structures: while-do-done
  1592.  
  1593.      A while loop is  simply a method for executing a statement list
  1594.      as long as a certain given condition is true.  For example,
  1595.  
  1596.         while [ ! -d ram:my_dir ]
  1597.         do
  1598.             sleep 10
  1599.         done
  1600.  
  1601.      which  is  an  endless loop which waits until a given directory
  1602.      exists  (because  another  process  created it).  It checks for
  1603.      the  existence of ram:my_dir every 10 seconds.  (Again test ex-
  1604.      pressions  will  be  explained  in  detail later).  As with if-
  1605.      then-else  statements, a while statement can examine the return
  1606.      code from a command.  A  particularly useful while loop of that
  1607.      form is the following:
  1608.  
  1609.         while read in_line
  1610.         do
  1611.              echo "We read: $in_line"
  1612.         done < input_file
  1613.  
  1614.      That  while  loop  executes as long as the read command returns
  1615.      TRUE.  The read  command returns FALSE upon reaching the end of
  1616.      the  input file, so the loop terminates then.  The entire while
  1617.      loop has its  input redirected from a given file.  In practice,
  1618.      of  course,  the  echo  statement would be replaced by the code
  1619.      which  accomplishes what you desire.  Here is  another example,
  1620.      like the above, but  which  is  combined with SKsh command sub-
  1621.      stitution:
  1622.  
  1623.         my_var = $(  while read in_line
  1624.                      do
  1625.                         echo "We Read: $in_line"
  1626.                      done < input_file
  1627.                   );
  1628.  
  1629.      That is  identical to the above loop, but saves the output in a
  1630.      variable called my_var.  You could then echo "$my_var"  to  re-
  1631.      trieve this output.
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.        SKsh Amiga Shell            Page 25                 User's Guide
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.        Control Structures: for-do-done
  1658.  
  1659.      SKsh  provides a for-do loop, but it differs from the for loops
  1660.      provided with  more  most  programming languages.  In SKsh, for
  1661.      loops are used  to  execute a series of statements for each pa-
  1662.      rameters in a list.  For example,
  1663.  
  1664.         for my_param in abc def ghi
  1665.         do
  1666.              echo "my_param = $my_param"
  1667.         done
  1668.  
  1669.      The  statement  list  inside the for loop is  executed once for
  1670.      each  parameter, and each time, the variable 'my_var' is set to
  1671.      the  parameter in question.  That is, the  first  time  through
  1672.      the loop, my_var  is  abc, the second time, def, and the third,
  1673.      ghi.   For  loops  are  useful when combined with wildcard pat-
  1674.      terns:
  1675.  
  1676.         for file in *.c
  1677.         do
  1678.              cp $file "dh0:backups/$file.bak"
  1679.         done
  1680.  
  1681.      That  loop  executes once for each c code file in  the  current
  1682.      directory,  copying the file to  the  directory dh0:backups and
  1683.      adding a  '.bak'  extension in the process.  After you gain ex-
  1684.      perience with  SKsh,  you  will  become proficient at executing
  1685.      similar  simple  programs from  the  command line.  Even though
  1686.      this loop is only four lines, it is quite useful.  In fact,  it
  1687.      could  be  shortened to one line  by  separating the components
  1688.      with ';'.  This loop has been extended to also copy .h files:
  1689.  
  1690.      for file in *.c *.h; do cp $file "dh0:backups/$file.bak"; done
  1691.  
  1692.      For loops  can  only  index parameters.  They cannot be used to
  1693.      count.  For that, you must use a while  loop  with  the  inc or 
  1694.      expr function.
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.        SKsh Amiga Shell            Page 26                 User's Guide
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.        Control Structures: case-esac
  1724.  
  1725.      SKsh  provides a  case  statement which can selected a group of
  1726.      statements to execute based on a key value.  For example:
  1727.  
  1728.         read answer
  1729.  
  1730.         case "$answer" in
  1731.            abc) echo 'you entered abc' ;;
  1732.            d?f) echo 'you entered d-something-f'
  1733.                 ;;
  1734.            *  ) echo 'you entered something else completely,'
  1735.                 echo "which was $answer"
  1736.                 ;;
  1737.         esac
  1738.  
  1739.      There are a few things  to  note  about  that  example,  First,
  1740.      there must  be  exactly one parameter following the "case" key-
  1741.      word  and  before the  "in"  keyword.   Here,  the  variable is
  1742.      double-quoted  in  case  it  should  happen to contain a space.
  1743.      Notice also that the "$answer"  variable is matched against one
  1744.      of  several wildcard patterns.  The last  option in the example
  1745.      uses a "*"  as  a  pattern; since the asterisk matches any pos-
  1746.      sible text, it acts as a default.
  1747.  
  1748.      Each branch  of  the  case  statement may contain any number of
  1749.      statements  or  shell  constructs, but the list must be  termi-
  1750.      nated  by  a  double  semicolon so SKsh knows when to start the
  1751.      next branch of the case statement.
  1752.  
  1753.      If the  selection text matches more than one branch of the case
  1754.      statement,  only  the  first  matching branch is executed.  The
  1755.      entire  case  construct must be terminated by a matching "esac"
  1756.      keyword (which is "case" spelled backwards).
  1757.  
  1758.      Newlines  can  generally be inserted or omitted at will in case
  1759.      statements.  For example, the following are identical:
  1760.  
  1761.         case
  1762.           dum
  1763.           in
  1764.             abc
  1765.             )
  1766.               echo FALSE
  1767.               ;;
  1768.             dum
  1769.             )
  1770.               echo TRUE
  1771.               ;;
  1772.         esac
  1773.  
  1774.      and:
  1775.  
  1776.         case dum in abc) echo FALSE;; dum) echo TRUE;; esac
  1777.  
  1778.  
  1779.        SKsh Amiga Shell            Page 27                 User's Guide
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.        Test Expressions
  1790.  
  1791.      Test  expression are used in if statements and while statements
  1792.      to  test   a   given   expression  and  return  TRUE  or  FALSE
  1793.      appropriately.  Test  expressions are enclosed in square brack-
  1794.      ets ('[ ]').  The following simple operators are available:
  1795.  
  1796.         -f fspec    TRUE if fspec exists and is a file
  1797.         -d fspec    TRUE if fspec exists and is a directory
  1798.         -s fspec    TRUE if fspec is a file and has a size of 0
  1799.         -r fspec    TRUE if fspec exists and is readable
  1800.         -w fspec    TRUE if fspec exists and is writable
  1801.         -x fspec    TRUE if fspec exists and is executable
  1802.         -S fspec    TRUE if fspec exists and the script bit is set
  1803.         -P fspec    TRUE if fspec exists and the pure bit is set
  1804.         -A fspec    TRUE if fspec exists and the archive bit is set
  1805.         -z string   TRUE if string has a length of 0
  1806.         -n string   TRUE if string has a non-zero length
  1807.         -m string   TRUE if string is the name of a mounted device
  1808.  
  1809.      The following comparison operators are available:
  1810.  
  1811.         n1 -eq n2   TRUE if n1 is numerically equal to n2
  1812.         n1 -ne n2   TRUE if n1 is numerically unequal to n2
  1813.         n1 -lt n2   TRUE if n1 is numerically less than n2
  1814.         n1 -gt n2   TRUE if n1 is numerically greater than n2
  1815.         n1 -le n2   TRUE if n1 is less than or equal to n2
  1816.         n1 -gt n2   TRUE if n1 is greater than or equal to n2
  1817.         s1 -ot s2   TRUE if the file s1 is older than the file s2
  1818.         s1 -nt s2   TRUE if the file s1 is newer than the file s2
  1819.         s1 = s2     TRUE if s1 is the same string as s2
  1820.         s1 != s2    TRUE if s1 is not the same string as s2
  1821.  
  1822.      Also, boolean operators are available:
  1823.  
  1824.         ! e1           TRUE if sub-expression e1 is false
  1825.         e1 -a e2       TRUE if e1 and e2 are both TRUE
  1826.         e1 -o e2       TRUE if e1 or e2 is TRUE
  1827.  
  1828.      Unquoted parentheses may be used to enforce precedence.
  1829.  
  1830.      Thus, the following expressions are all TRUE:
  1831.  
  1832.         [ 1 -lt 3 ]
  1833.         [ 3 -lt 2 -o 1 -lt 0 -o 3 -eq 3 ]
  1834.         [ -z '' ]
  1835.         [ -n "hi" ]
  1836.         [ ! -z "hi" ]
  1837.         [ a = 'a' ]
  1838.         [ 'xyz' != 'abc' ]
  1839.         [ -d 'c:' ]
  1840.         [ -f 'c:dir' -a -f 's:startup-sequence' ]
  1841.  
  1842.  
  1843.  
  1844.  
  1845.        SKsh Amiga Shell            Page 28                 User's Guide
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.      The  boolean  and  operator has  a  higher  precedence than the
  1856.      boolean -o operator.  Note also  that  test  expressions do not
  1857.      print their  result; they simple set the return code, which can
  1858.      then be tested  for.   A  return code of zero means TRUE.  Here
  1859.      is an example usage of a test expression:
  1860.  
  1861.         i = 1
  1862.         while [ $i -le 10 ]
  1863.         do
  1864.            echo "index variable = $i"
  1865.            inc i
  1866.         done
  1867.  
  1868.      Here is another example:
  1869.  
  1870.         function my_func {
  1871.            if [ $# -ne 3 ]
  1872.            then
  1873.               echo "This function requires exactly 3 parameters"
  1874.               return
  1875.            fi
  1876.         }
  1877.  
  1878.      The  inc  command  is  simply a  way  to  increment a variable.
  1879.      There are other ways do it, but inc is the fastest.
  1880.  
  1881.      Test  expressions  are  related to, but should not be  confused
  1882.      with, the  expr command.  They may freely contain newline char-
  1883.      acters, unlike the Un*x version.
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.        SKsh Amiga Shell            Page 29                 User's Guide
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.        Sub-Shell Execution
  1922.  
  1923.      SKsh  provides  two  mechanisms for grouping commands; they are
  1924.      closely  related both in  behavior and syntax, but differ in an
  1925.      important way.
  1926.  
  1927.      If  a  series  of  statements is grouped  within  either curly-
  1928.      braces  '{ }' or parentheses '( )', that statement list is said
  1929.      to be executed within a sub shell.  For example:
  1930.  
  1931.         { echo foo; echo bar }
  1932.      and
  1933.         ( read foo; read bar )
  1934.  
  1935.      are both sub-shell statements.   Subshells group their enclosed
  1936.      commands, so that all the  commands within the subshell share a
  1937.      common environment.  One use for this is to give all  the  com-
  1938.      mands a common input or output.  For example:
  1939.  
  1940.         { c:status
  1941.           echo "Done with status command"
  1942.           c:dir
  1943.           echo "Done with dir command"
  1944.         } > out_file
  1945.  
  1946.      The  output of all  the  commands within the subshell goes to a
  1947.      common file.  This works for input, as well:
  1948.  
  1949.         { read foo; read bar } < in_file
  1950.  
  1951.      If you tried  to  redirect the input of each read command sepa-
  1952.      rately,  both  'foo'   and   'bar'   would   contain  the  same
  1953.      information.   By   using a sub-shell, the reads are sequential
  1954.      from the input file.
  1955.  
  1956.      The  parenthetical  subshell syntax differs from the above form
  1957.      only  in  that  any  variables declared within the subshell are
  1958.      local.  For example,
  1959.  
  1960.         [dh0:] answer = 42; echo $answer
  1961.              42
  1962.         [dh0:]: ( answer = 7; echo $answer )
  1963.              7
  1964.         [dh0:]: echo $answer
  1965.              42
  1966.  
  1967.      Notice  that  the  answer  variable is 42 both before and after
  1968.      the  subshell, but is 7 within  it.   Because this type of sub-
  1969.      shell  allocates space  for  local variables, the first form is
  1970.      both faster and uses less memory.  It  is  the  preferred form,
  1971.      unless you do  in  fact  need  local variables.  (Functions and
  1972.      aliases  declared within  the  parenthetical subshell are local
  1973.      as well).
  1974.  
  1975.  
  1976.  
  1977.        SKsh Amiga Shell            Page 30                 User's Guide
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.        File Name Mapping
  1988.  
  1989.      When SKsh sees an unquoted file name, it  maps  the  file  name
  1990.      from a Unix style file name to an  AmigaDos  style  file  name.
  1991.      The Unix style  has  several advantages.  First and foremost, a
  1992.      single  dot ('.') can be used to  specify  the  current working
  1993.      directory. For example,
  1994.  
  1995.         [dh0:]: assign this_dir: .
  1996.         [dh0:]: HOME=.
  1997.  
  1998.      assigns  'this_dir'  (a  device) to the  current working direc-
  1999.      tory, and then  sets  the  SKsh  home  directory to the current
  2000.      directory.  The dot can be used  in  any  command, such as 'cp'
  2001.      or 'mv', but  it  cannot be quoted or it looses its magic prop-
  2002.      erties and becomes just a dot.  For example,
  2003.  
  2004.         [dh0:]: echo .
  2005.              dh0:appl/excellence!/documents/SKSH
  2006.         [dh0:]: echo "."
  2007.              .
  2008.  
  2009.      In  addition,  a  path  beginning  with  a  slash ('/') will be
  2010.      mapped by SKsh to be an AmigaDos  absolute path name instead of
  2011.      a relative path name.  For example,
  2012.  
  2013.         run lse /usr/src/SKsh/Parser.y
  2014.  
  2015.      really  edits the file 'dh0:usr/src/SKsh/Parser.y' if the  cur-
  2016.      rent  device is dh0:.  (Note for advanced users: the ROOT vari-
  2017.      able,  described in the Reference manual, can be used to change
  2018.      the root point).  Also, SKsh  maps  two  sequential dots ('..')
  2019.      to be the parent directory of the current directory 
  2020.      (which in AmigaDos is specified with a slash):
  2021.  
  2022.         run emacs ../../my_file.c
  2023.  
  2024.      The file my_file.c  in  the  directory  two  levels  above  the
  2025.      current directory is loaded into emacs.
  2026.  
  2027.      A tilde ('~') can be used to specify the contents of  the  HOME
  2028.      variable.  For example, if HOME is 'sys:usr/src/SKsh',
  2029.  
  2030.         [dh0:]: echo ~/Parser.y
  2031.              sys:usr/src/SKsh/Parser.y
  2032.  
  2033.      SKsh can  be  instructed not to perform this file name mapping.
  2034.      See the options command for details.
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.        SKsh Amiga Shell            Page 31                 User's Guide
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.        SKsh Scripts
  2054.  
  2055.      If a file  containing SKsh commands is in the SKsh search path,
  2056.      and has its script  bit  set,  SKsh  will  execute the file di-
  2057.      rectly as if it was  a  binary file; there is no need to use an
  2058.      "execute"  or  other  special command.  Normally, SKsh executes
  2059.      the file in its  own  sub-shell.   Thus,  variables, functions,
  2060.      and  aliases  defined within the script file are  local.   SKsh
  2061.      can also "source" files (execute them but not in a subshell).
  2062.  
  2063.      SKsh will  happily co-exist with scripts from other shells.  If
  2064.      SKsh  detects a file with the script bit set, it first examines
  2065.      the  first  two  characters of the file.  If they are  '#!'  or
  2066.      ';!' SKsh reads the rest of the  first  line,  appends the name
  2067.      of the script file, and passes the string  to  AmigaDos  to  be
  2068.      executed.  For  example, on my system I have scripts from SKsh,
  2069.      Matt Dillon's shell, and  the  AmigaDos  "execute" command.  My
  2070.      scripts either begin with:
  2071.  
  2072.         #!sys:bin/shell
  2073.  
  2074.      if the script is to be executed by Matt's shell, or
  2075.  
  2076.         ;!c:execute
  2077.  
  2078.      if the file is an  "execute" script.  Since the first character
  2079.      is  recognized  by  the  appropriate shell  as  a  comment, the
  2080.      script runs fine, and SKsh knows to pass  execution to the cor-
  2081.      rect shell.  It  is  important that there are no leading blanks
  2082.      or  newlines  before the '#!' or ';!'; they must be  the  first
  2083.      two  characters of the file.   This  mechanism can be used with
  2084.      any other Amiga shell  that  recognizes '#' or ';' as a comment
  2085.      character.
  2086.  
  2087.      If the script bit is not set, SKsh will  ignore the file unless
  2088.      you  explicitly use the 'source' command.  Also, if  the  shell
  2089.      does  not  automatically  exit  after executing the script, you
  2090.      must  include  an  explicit  exit  statement at the end of  the
  2091.      script (such as with Matt Dillon's Shell).
  2092.  
  2093.      (Note: there seems to be a  bug  someplace with using ;!execute
  2094.      for AmigaDos  execute scripts.  It seems that execute sometimes
  2095.      returns  before  the  script  has  finished running, and things
  2096.      tend to get a bit confused.  I do not think  this  is  an  SKsh
  2097.      problem, since I run the  execute command the same way as I run
  2098.      anything else).
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.        SKsh Amiga Shell            Page 32                 User's Guide
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.        Command Line Editing and History
  2120.  
  2121.      SKsh  provides  mechanisms  for  recalling and editing previous
  2122.      commands.  To  obtain a list of previous commands, use the his-
  2123.      tory  command.   By   default, SKsh keeps the  previous 32 com-
  2124.      mands,  although  this  number can be  changed  by  setting the 
  2125.      HISTSIZE variable.
  2126.  
  2127.      In  addition,  command  line  editing is  available (but can be
  2128.      turned  off  -  see  the  options command).  The following keys
  2129.      have  special  meaning (the caret mark means hold down the con-
  2130.      trol key and press the following character):
  2131.  
  2132.         ^p or up arrow           - recall previous command
  2133.         ^n or down arrow         - recall next command
  2134.         ^b or left arrow         - move cursor left
  2135.         ^f or right arrow        - move cursor right
  2136.         ^m or return             - accept and execute current line
  2137.         ^a or shift-left         - move to beginning of line
  2138.         ^e or shift-right        - move to end of line
  2139.         ^k                       - kill to end of line
  2140.         ^l                       - redraw the current line
  2141.         ^d or delete key         - delete current character
  2142.         ^h or backspace          - delete previous character
  2143.         ^g                       - kill (erase) current line
  2144.         esc-f                    - move forward one word
  2145.         esc-b                    - move backward one word
  2146.         esc-d                    - delete the next word
  2147.         esc-backspace            - delete the previous word
  2148.         esc-< or shift-up        - move to first line in history
  2149.         esc-> or shift-down      - move to last line in history
  2150.         esc-esc or tab           - filename completion
  2151.         esc-=                    - list matching file names
  2152.         esc-*                    - insert matching file names
  2153.         esc-.                    - insert last param of prev line
  2154.         esc-/                    - insert 'tail' of previous line
  2155.         esc-#                    - insert '#' as 1st char of line
  2156.         ^r                       - reverse search for line
  2157.         ^o                       - execute line, move to next
  2158.         ^u                       - multiply next command by 4
  2159.         ^z                       - toggle insert/overstrike mode
  2160.         function keys            - insert defined text
  2161.  
  2162.      The  basic  editing commands are self explanatory, but the oth-
  2163.      ers may not be.   The  reverse search command is used to search
  2164.      for a  string  in  the  history list, and then display the line
  2165.      containing that string for  further editing.  For example, sup-
  2166.      pose your history list contained 4 lines, as follows:
  2167.  
  2168.         [dh0]: history
  2169.              1: echo 'This is a test'
  2170.              2: version
  2171.              3: date
  2172.              4: history
  2173.  
  2174.  
  2175.        SKsh Amiga Shell            Page 33                 User's Guide
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.      Then, at the SKsh prompt, type a substring  from  any  previous
  2187.      command:
  2188.  
  2189.         [dh0:]: test
  2190.  
  2191.      When  you  press  ^r,  the  most  recent  line  containing  the
  2192.      substring will be displayed and available for editing:
  2193.  
  2194.         [dh0:]: echo 'This is a test'
  2195.  
  2196.      This line can be  edited, or accepted as is by pressing return.
  2197.      If  it  is  not  the  correct line,  pressing ^r yet again will
  2198.      start  the  reverse search again beginning with the line previ-
  2199.      ous to the one displayed.   Thus,  multiple ^r's can be used to
  2200.      access  the  desired line.  The search can be made to find only
  2201.      lines  which  have  a  matching  prefix, or lines that  have  a
  2202.      matching  substring;  this  behavior is changeable with the op-
  2203.      tions command.
  2204.  
  2205.      If the line is changed in any way, it  will  be  re-entered  at
  2206.      bottom of the  history list as a new command.  If it is not ed-
  2207.      ited, it  will  simply be executed, but not inserted again into
  2208.      the  history  list  (although this behavior can be changed with
  2209.      the options command.
  2210.  
  2211.      The ^o  key  is  useful for executing a series of commands mul-
  2212.      tiple times.  Suppose your history list looks like this:
  2213.  
  2214.         1: echo $HISTSIZE
  2215.         2: date
  2216.         3: echo 'command 1'
  2217.         4: echo 'command 2'
  2218.         5: echo 'command 3'
  2219.  
  2220.      Use the ^p key or up  arrow to move to the 3rd line.  By press-
  2221.      ing the  ^o  key,  that  line  is  executed, and SKsh remembers
  2222.      which line that  was.   By  pressing ^o again, the next line is
  2223.      executed.   Upon   reaching the end of the list, SKsh moves  to
  2224.      the first line upon which ^o was used.  In  this  manner, 'com-
  2225.      mand  1',   'command  2',  and  'command  3'  would  be  echoed
  2226.      repeatedly.    Using any other movement or editing command will
  2227.      cause  SKsh  to  forget which line was the first, and you  will
  2228.      have to move to it again.
  2229.  
  2230.      The ^u key causes the  next  command to be repeated four times.
  2231.      For  example,  pressing ^u followed by the '-' key inserts four
  2232.      dashes.    Pressing ^u  followed by the delete key deletes four
  2233.      characters.  The  action of ^u is recursive;  two ^u's in a row
  2234.      will  repeat the next  command 16 times.  Three would repeat 64
  2235.      times.     Therefore,  to  insert  a  row  of  64  dashes,  use
  2236.      '^u^u^u-'.
  2237.  
  2238.  
  2239.  
  2240.  
  2241.        SKsh Amiga Shell            Page 34                 User's Guide
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.      The  maximum line length in SKsh is  currently 1023 characters.
  2252.      Attempting  to  enter lines longer than this from the  keyboard
  2253.      will result in an error message.
  2254.  
  2255.      If you press a  function key, SKsh will examine the contents of
  2256.      the  variable with the  same  name.   For  example, pressing f1
  2257.      would cause SKsh  to  look  for  a  variable named 'f1', and if
  2258.      found,  insert the text it contains as if you had typed it.  If
  2259.      the text ends in a newline, SKsh  will  execute the command im-
  2260.      mediately;  otherwise, it will simply display it for editing or
  2261.      execution.  For example:
  2262.  
  2263.         [dh0:]: f1="echo testing"
  2264.  
  2265.      would  would  just  display "echo  testing" when f1 is pressed,
  2266.      but:
  2267.  
  2268.         [dh0:]: f1="echo testing\n"
  2269.  
  2270.      would  execute the  command as well.  The variables f11 through
  2271.      f20 may be used to set the shifted function keys.
  2272.  
  2273.      <esc>.  will  insert the  last  parameter of the previous line.
  2274.      For example, suppose you have typed:
  2275.  
  2276.         [dh0:]: ll some_file_name
  2277.  
  2278.      Now, you can type:
  2279.  
  2280.         [dh0:]: rm
  2281.  
  2282.      and press <esc>., which will insert some_file_name:
  2283.  
  2284.         [dh0:]: rm some_file_name
  2285.  
  2286.      Similarly, <esc>/ will  insert the "tail" of the previous line;
  2287.      that is, all of the line except the first parameter.
  2288.  
  2289.      In  addition  to  the  interactive editing facilities, a single
  2290.      command  can  be  executed with the  'history -e' command.  You
  2291.      can  specify  either a substring of  the  command, its absolute
  2292.      number,  or  its  relative  number by  using a negative offset.
  2293.      For  example, given the above  history list, all of the follow-
  2294.      ing would echo 'command 2':
  2295.  
  2296.         [dh0:]: history -e 'd 2'
  2297.         [dh0:]: history -e 4
  2298.         [dh0:]: history -e -2
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.        SKsh Amiga Shell            Page 35                 User's Guide
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.      The  executed  command is not placed at the end of the  history
  2318.      list (see the  options command).  For convenience, 'history -e'
  2319.      has  been  aliased  to  '!'.   Also,   'history -e -1' has been
  2320.      aliased  to  '!!'  (similar  to  csh, except that in SKsh there
  2321.      must be  a  space  between the '!' and the parameter).  For ex-
  2322.      ample,
  2323.  
  2324.  
  2325.         [dh0:]: ! test      # last line containing 'test'
  2326.         [dh0:]: !!          # previous command
  2327.         [dh0:]: ! -2        # two commands back
  2328.         [dh0:]: ! 3         # command number 3
  2329.  
  2330.      If you type a  command line that would wrap onto the next line,
  2331.      SKsh  will  instead scroll the line  12  characters to the left
  2332.      and  let  you  continue typing.  If you move off either side of
  2333.      the  "sliding  window", sksh will  adjust the line accordingly.
  2334.      If this  behavior does not appear to be acting correctly, check
  2335.      the value of  the  COLUMNS and PNPC variables, described in the
  2336.      Reference  Manual.   The  COLUMNS variable should be set to the
  2337.      number  of  columns in  the  current window, and PNPC should be
  2338.      set to  the  number of non-printable ANSI control characters in
  2339.      the SKsh  prompt  (21  for  the  default prompt).  If either of
  2340.      these  numbers are wrong, long lines  will  display improperly.
  2341.      (In SKsh 1.2  or  later,  the  COLUMNS variable is normally set
  2342.      automatically.) Also, SKsh line  editing can be turned off com-
  2343.      pletely;  see  the  options command for details.  In this case,
  2344.      no  line  scrolling is performed.  If  the  COLUMNS variable is
  2345.      set to less than 15, SKsh will get confused.
  2346.  
  2347.      (Note for  advanced users: there are several ways to change the
  2348.      behavior of  the  command line editing functions.  For example,
  2349.      set  the  "setmap" command, the MAXDIST variable, and the LLMIN
  2350.      variable.  Also, the keymaps be  be  changed  to  a  completely
  2351.      different  editing style in order to, for example,  emulate  vi
  2352.      instead of emacs).
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.  
  2373.        SKsh Amiga Shell            Page 36                 User's Guide
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.        Filename Completion
  2384.  
  2385.      SKsh  supports  filename  completion using <esc><esc> or <tab>.
  2386.      For  example,  suppose your  current working directory contains
  2387.      the following files:
  2388.  
  2389.         my_file.c
  2390.         another_c_file.c
  2391.         this_is_a_long_filename
  2392.         test_file2
  2393.         test_file3
  2394.         picture.ham
  2395.         picture1.ham
  2396.         picture2.ham
  2397.  
  2398.      If  SKsh  command  line  editing is turned on (see the  options
  2399.      command),  you  can  insert any file name into the command line
  2400.      by  typing part of the file  name  and  pressing the escape key
  2401.      twice.  For example, suppose you typed:
  2402.  
  2403.         [dh0:]: cat ano
  2404.  
  2405.      and pressed <tab>.  SKsh would fill in the  rest  of  the  file
  2406.      name for you:
  2407.  
  2408.         [dh0:]: cat another_c_file.c
  2409.  
  2410.      In fact, since 'a' is  enough  to  uniquely  specify  the  file
  2411.      name, you could have typed 'a<tab>' for the  same  effect.   In
  2412.      the case of 'test_file2' and  'test_file3'  above,  typing 'te'
  2413.      is not enough to uniquely specify the file, but SKsh will  help
  2414.      here too by filling in as much as it can:
  2415.  
  2416.         [dh0:]: echo te
  2417.  
  2418.      (press <tab>)
  2419.  
  2420.         [dh0:]: echo test_file
  2421.  
  2422.      You would then  have  to  type  either '2' or '3', but you have
  2423.      still saved 7 characters of typing.
  2424.  
  2425.      Filename  completion is  useful not only to save typing, but to
  2426.      insure that you have not mis-typed the file name.  You can  use
  2427.      filename completion on paths, as well:
  2428.  
  2429.         [dh0:]: sys:S                      (press <tab>)
  2430.         [dh0:]: sys:System/Fo              (type /Fo and <tab>)
  2431.         [dh0:]: sys:System/Format
  2432.  
  2433.      The tab key can also be used for  filename  completion if it is
  2434.      mapped accordingly.
  2435.  
  2436.  
  2437.  
  2438.  
  2439.        SKsh Amiga Shell            Page 37                 User's Guide
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.      By  default, case  is  not  significant in filename completion,
  2450.      although this behavior can be changed with the option command.
  2451.  
  2452.      In  SKsh  1.1  or  later,  there  are  two  additional filename
  2453.      completion features.  You can type a  partial filename (option-
  2454.      ally  using  wildcard  patterns), press <esc>=, and  SKsh  will
  2455.      list  all  matching files as if  an  '*'  were  appended to the
  2456.      filename you typed.  It will the re-display  your  command line
  2457.      so you can continue typing:
  2458.  
  2459.         [dh0:]: show pic                 ( press <esc>=)
  2460.            1) picture.ham
  2461.            2) picture1.ham
  2462.            3) picture2.ham
  2463.         [dh0:]: show pic
  2464.  
  2465.      You  can  then  continue  typing, but you can see the  matching
  2466.      files.  This  is  useful when you have typed part of a command,
  2467.      and  then  think  'Hmm,  what  was  that  file  called?'.   The
  2468.      filename you type can contain wildcard patterns, as well.
  2469.  
  2470.      Also in SKsh 1.1 or  later,  <esc>*  will  insert matching file
  2471.      names  in  the  command line.  Again, given the above  example,
  2472.      you could type:
  2473.  
  2474.         [dh0:]: show *.ham
  2475.  
  2476.      and press <esc>*.  SKsh will re-write the  command line as fol-
  2477.      lows:
  2478.  
  2479.         [dh0:]: show picture.ham picture1.ham picture2.ham
  2480.  
  2481.      Using  <esc>*,  the  pattern must match the files exactly; SKsh
  2482.      does not append a '*' for you as it does with <esc>=.
  2483.  
  2484.      In SKsh 1.5 or later, filename  completion will insert a "/" at
  2485.      the end of the name  if  the  name  wholely matched a directory
  2486.      name.    Similarly, it will  insert a space if the name wholely
  2487.      matched a file name.  This makes it easy to  tell  whether  the
  2488.      match was  complete, and if so, whether a file or directory was
  2489.      matched.
  2490.  
  2491.      SKsh  is,  I  believe, the first Amiga shell to  offer filename
  2492.      completion.  You'll find it  addictive.   It  works  best  with
  2493.      hard or ram disks, since the directory seek speed is faster.
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.        SKsh Amiga Shell            Page 38                 User's Guide
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.        Advanced Topics: Using SKsh with ARexx
  2516.  
  2517.      SKsh may be used with the  ARexx package available from William
  2518.      S. Hawes.  ARexx is a  commercial package which provides a com-
  2519.      mon script  language for different AmigaDos programs.  ARexx is
  2520.      available from many  Amiga  software stores, and also from most
  2521.      mail order houses.  It will also be bundled with AmigaDos 2.0.
  2522.  
  2523.      SKsh  will  normally  not  attempt to open an ARexx  port  upon
  2524.      invocation.  However, if invoked with the "-a" flag:
  2525.  
  2526.      If SKsh is invoked with the "-a" flag:
  2527.  
  2528.        sksh -a
  2529.  
  2530.      then SKsh  will  attempt to open ARexx with a default port name
  2531.      (see  below).   The   actual port  name  will  be  put  in  the
  2532.      AREXX_PORT variable.   This  variable will be unset if SKsh was
  2533.      not able to open the ARexx port.
  2534.  
  2535.      Each  invocation of SKsh must have a unique  ARexx  port  name.
  2536.      This  is  necessary so that ARexx can uniquely specify the des-
  2537.      tination for ARexx commands.  SKsh has an  algorithm for deter-
  2538.      mining this name.  It will  first  attempt to use an ARexx port
  2539.      name of "SKSH" (all caps).  If this fails  (perhaps because an-
  2540.      other  invocation of SKsh has used this name), then SKsh  tries
  2541.      "SKSH_$CLINUM" where $CLINUM  is  replaced with the cli process
  2542.      number  of  this  invocation of SKsh.  If this fails also, then
  2543.      SKsh gives up and does not use an ARexx port.
  2544.  
  2545.      SKsh can be  told  to  use  any  specific port name by invoking
  2546.      SKsh as follows:
  2547.  
  2548.         sksh -p MYPORTNAME
  2549.  
  2550.      SKsh  will  then  use  MYPORTNAME as an ARexx port name if  the
  2551.      port is available.  This name works best if  it  is  all  caps;
  2552.      otherwise it must be quoted in ARexx scripts.
  2553.  
  2554.      Any  other  process may be used to  send  ARexx  commands to an
  2555.      SKsh which has an  open  ARexx  port.   However, an SKsh cannot
  2556.      send ARexx commands to itself.  This will be explained below.
  2557.  
  2558.      SKsh  is  capable  of  asynchronously detecting ARexx messages.
  2559.      That is, there  is  no  special SKsh command used to tell it to
  2560.      listen to ARexx commands.  It  will  "see"  ARexx  commands any
  2561.      time it is not busy  doing something else; ie, at any time when
  2562.      it  is  displaying the  SKsh  prompt  and  waiting for keyboard
  2563.      input.   This  is  the  reason that SKsh cannot send ARexx com-
  2564.      mands to  itself.   It  invokes the ARexx script which does not
  2565.      return  until  all  the  commands are executed.  But if one  of
  2566.      these  commands is sent to the same SKsh, the SKsh won't see it
  2567.      until  SKsh  finishes  running the script.  This creates a race
  2568.      condition which will loop forever.   SKsh  protects you against
  2569.  
  2570.  
  2571.        SKsh Amiga Shell            Page 39                 User's Guide
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.      this  circumstance  by  temporarily closing its ARexx port when
  2582.      executing  external commands.  Note that in spite of this,  one
  2583.      SKsh can send ARexx commands to a separate invocation of SKsh.
  2584.  
  2585.      To  test  the  ARexx  port,  create  an  ARexx  script   called
  2586.      "mytest.rexx" with the following contents:
  2587.  
  2588.         /* This script tests the SKsh ARexx port */
  2589.  
  2590.         address 'MY_SKSH'     /* connect to a specific SKsh */
  2591.         'echo'
  2592.         'version'             /* call the SKsh version command */
  2593.         'echo'
  2594.         'info -a'             /* call SKsh info command */
  2595.         exit
  2596.  
  2597.      Now,  obtain a new  AmigaDos  shell  window (using c:newshell).
  2598.      If  this  window  automatically  invokes SKsh, you will want to
  2599.      use the "quit" command to exit that SKsh.
  2600.  
  2601.      Invoke SKsh in  the  new  window using "sksh -P MY_SKSH" to ob-
  2602.      tain an ARexx port of the proper name.  When this  SKsh  starts
  2603.      running,  type  "echo  $AREXX_PORT" to verify that SKsh was in-
  2604.      deed able to allocate the desried ARexx port.
  2605.  
  2606.      Invoke  another SKsh by your  normal method, and in it type "rx
  2607.      mytest.rexx".   (The   rx command should be provided as part of
  2608.      your  ARexx  package).  The ARexx script will now run, and  in-
  2609.      voke  the  proper  commands in the first SKsh.  Note that  SKsh
  2610.      obtains the  input and output streams from ARexx, and therefore
  2611.      the  output will go to  the  window which invoked "rx", and not
  2612.      to the SKsh window which is actually running the commands.
  2613.  
  2614.      Not also that  due  to  a  limitation in ARexx, multi-line SKsh
  2615.      commands cannot be passed via the SKsh ARexx port.
  2616.  
  2617.      I  recommend that if an ARexx port is not needed in SKsh,  that
  2618.      it  not  be  invoked with  either "-a" or "-p PORTNAME" so that
  2619.      the resources needed for the ARexx port are not allocated.
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.  
  2637.        SKsh Amiga Shell            Page 40                 User's Guide
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.        Advanced Topics: && and || operators
  2648.  
  2649.      The  && operator may be used to link commands or control struc-
  2650.      tures in such a way  that  the  second will be executed only if
  2651.      the  first  succeeds (or fails).  This can  be  useful to avoid
  2652.      "if"  statements when only  one  or  two  commands is executed.
  2653.      The  &&  operator executes its right side only if its left side
  2654.      is true,  and  the  || operator executes the right side only if
  2655.      the left side is false.
  2656.  
  2657.      For  example,  to  remove the file 'foo' only if it is success-
  2658.      fully copied to ram:
  2659.  
  2660.         cp foo ram: && rm foo
  2661.  
  2662.      That is considerably more concise than the alternative:
  2663.  
  2664.         if cp foo ram:
  2665.         then
  2666.           true
  2667.         else
  2668.           rm foo
  2669.         fi
  2670.  
  2671.      More than one command can be chained.  For example, consider:
  2672.  
  2673.         cp foo ram: && rm foo && echo 'copy succeeded'
  2674.  
  2675.      Or, to execute a 'cleanup' function only if a "rm" fails:
  2676.  
  2677.         rm myfile || cleanup
  2678.  
  2679.      If  &&  and  || are used  together, execution is left to right.
  2680.      For example,
  2681.  
  2682.         cp foo ram: && rm foo || echo 'remove failed'
  2683.  
  2684.      To  chain  larger  numbers of  commands, it may be necessary to
  2685.      increase  your  RECUR_DEPTH variable (see Reference.doc for de-
  2686.      tails on RECUR_DEPTH.
  2687.  
  2688.      Complex  commands as well as simple ones can be chained.   Con-
  2689.      sider that in  an  "if"  statement, the return code from the if
  2690.      clause  is  the  return code from  the  last  command executed.
  2691.      Therefore:
  2692.  
  2693.         if [ -f ram:foo ]
  2694.         then
  2695.           some_operation_on_file
  2696.         elif [ -d ram:foo ]
  2697.         then
  2698.           some_operation_on_dir
  2699.         fi || echo 'operation failed!' && my_abort_cmd
  2700.  
  2701.  
  2702.  
  2703.        SKsh Amiga Shell            Page 41                 User's Guide
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.        Advanced Topics: [ ] Operator Used Independently
  2714.  
  2715.      [ expr  ]  style  expressions may be used independently of "if"
  2716.      or "while"  structures.   This  is  especially useful when com-
  2717.      bined  with  the  && and || operators explained above.  For ex-
  2718.      ample, to set the  variable "myvar" to "blah" only if "ram:foo"
  2719.      is a file:
  2720.  
  2721.         [ -f ram:foo ] && myvar=blah
  2722.  
  2723.      As another example,  consider  the  following  script  fragment
  2724.      from the SKsh 1.7 "man" script:
  2725.  
  2726.         [ -f "MAN:$1.MAN" ]                 && _fspec="MAN:$1.MAN"
  2727.         [ -z "$_fspec" -a -f "MAN:$1.doc" ] && _fspec="MAN:$1.doc"
  2728.         [ -z "$_fspec" -a -f "MAN:$1.txt" ] && _fspec="MAN:$1.txt"
  2729.  
  2730.         [ -z "$_fspec" ] && echo "No manual entry for $1" && return
  2731.  
  2732.      These four lines search  the  MAN:  directory for a file ending
  2733.      in .MAN, .doc, or .txt, and sets "_fspec"  to  the  first  such
  2734.      file found.  It  then  exits if no file is found.  The alterna-
  2735.      tive "if" statement is much more cumbersome.
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.        SKsh Amiga Shell            Page 42                 User's Guide
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.        Advanced Topics: Variable Substitution Forms
  2780.  
  2781.      SKsh 1.7  and  later  provide  several  methods  to  substitute
  2782.      variable values into strings.  The following substitutions  can
  2783.      be included in a string:
  2784.  
  2785.         ${var}         - Like $var, but ${a}text can be used to  ex-
  2786.                          pand $a in front of  "text",  since  $atext
  2787.                          would  try  to  expand the "atext" variable
  2788.                          instead of the "a" variable.
  2789.  
  2790.         ${#var}        - Expands to the text length of $var.
  2791.  
  2792.         ${var:-word}   - Expands to $var if $var is set.   Otherwise
  2793.                          expands  to  word,  which  may  itself be a
  2794.                          variable (as in ${FOO:-$PWD} ).
  2795.  
  2796.         ${var:=word}   - Similar to  ${var:-word},  but  assigns the
  2797.                          result to "var" if it is  not  already set.
  2798.                          Useful for  assigning defaults to variables
  2799.                          while simultaneously using the result.
  2800.  
  2801.      Some examples:
  2802.  
  2803.         [dh0:]: zabcd=----; z=Z       # some variables
  2804.         [dh0:]: echo  $zabcd          # echoes contents of zabcd
  2805.              ----
  2806.         [dh0:]: echo ${z}abcd         # contents of z, plus abcd
  2807.              Zabcd
  2808.         [dh0:]: echo ${#zabcd}        # length of variable zabcd
  2809.              4
  2810.         [dh0:]: echo "foo = $foo"     # foo is empty
  2811.              foo =
  2812.                                       # ${foo:-stuff} = stuff
  2813.         [dh0:]: echo ${foo:-TESTING} ${foo:-$zabcd}
  2814.              TESTING ----
  2815.         [dh0:]: echo "foo = $foo"     # foo is still empty
  2816.              foo =
  2817.         [dh0:]: echo ${foo:=BLAH}     # assigns BLAH to foo
  2818.              BLAH
  2819.         [dh0:]: echo "foo = $foo"     # foo is now BLAH
  2820.              foo = BLAH
  2821.         [dh0:]: echo ${foo:=ZZZ}      # foo is still BLAH
  2822.              BLAH
  2823.         [dh0:]: echo ${foo:-ZZZ}      # returns BLAH, not ZZZ
  2824.              BLAH
  2825.  
  2826.  
  2827.      For an example of a real usage,  consider  the  line  from  the
  2828.      SKsh 1.7 "man" script which examines a file using  the  program
  2829.      name in the $PAGER variable if set, or "more" if not.
  2830.  
  2831.         ${PAGER:-more} "$_fspec"
  2832.  
  2833.  
  2834.  
  2835.        SKsh Amiga Shell            Page 43                 User's Guide
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.  
  2843.  
  2844.  
  2845.        Advanced Topics: Using Shared SKsh Modes
  2846.  
  2847.      SKsh  1.7  and  later  support three "shared" modes, started by
  2848.      invoking with SKsh with no  parameters, the "-s" option, or the
  2849.      "-S" option.  Each  has  certain advantages, but some modes may
  2850.      not  be  transparent in  their  usage (see below).  These modes
  2851.      are  called  "slightly  shared",  "somewhat shared", and  "very
  2852.      shared" according to how much data is shared between shells.
  2853.  
  2854.      The  default mode ("slightly  shared")  causes  the  second and
  2855.      subsequent  simultaneous executions of SKsh to share error mes-
  2856.      sages,  help  messages, and usage messages with the first SKsh.
  2857.      That  is,  the  first  time  you  invoke SKsh, it will load the
  2858.      sksh:sksh.msg file into memory.   If  you  then  start  another
  2859.      SKsh  while  the  first  is  still  running, it will  not  load
  2860.      sksh:sksh.msg.  It  will  instead find and use the message file
  2861.      already loaded in ram by the first SKsh.  When all  SKsh  invo-
  2862.      cations exit,  the  message file will be freed.  This will save
  2863.      about 6500 bytes of memory  for  the  second and future invoca-
  2864.      tions and slightly speed invocation.
  2865.  
  2866.      The  second shared mode ("somewhat shared"), using the "-s" pa-
  2867.      rameter, will cause SKsh to  share  the  messages listed above,
  2868.      and also the main hash table used to store  keyword names, etc.
  2869.      This  table  is  not   user   modifiable,  so  this  is  nearly
  2870.      transparent.   There  is,  however, one limitation present with
  2871.      "-s" which is not present  with  the  default shared mode.  The
  2872.      second SKsh (known as  the  "slave"  shell)  can  exist only as
  2873.      long as the first  (known  as  the  "master" shell) is running.
  2874.      If the  master shell exits, ALL slave shells will exit upon the
  2875.      next  command, and an abort message will be printed.  "Somewhat
  2876.      shared" mode saves about 12K per execution.
  2877.  
  2878.      The third shared  mode  ("very  shared"),  using the "-S" flag,
  2879.      will cause SKsh to share  all  of  the  data  mentioned for the
  2880.      "slightly  shared"  and  "somewhat shared" modes, and  also  to
  2881.      share the main  user  symbol table. This table is used to store
  2882.      variables,  function  definitions,  and  aliases.  Sharing this
  2883.      table has one  important advantage: since variables, functions,
  2884.      and aliases which are set  up  by  the  .skshinit  and  .skshrc
  2885.      files are put in this table, any  SKsh  after the first started
  2886.      with "-S" will not need to read these  files.   This  can  dra-
  2887.      matically  improve  startup times.  For  example, on my system,
  2888.      my s:shell-startup  file  contains the lines "setfont source 10
  2889.      window" and "sksh -S".  SKsh has been made resident.  The  time
  2890.      necessary  to  create  a  new  window and get a shell prompt is
  2891.      about half a second.  "very shared" mode shares  the  disadvan-
  2892.      tage  of  "somewhat shared" mode in that the  master shell must
  2893.      exist; if it  exits, the slave shells will detect this and exit
  2894.      immediately.  It also has  a  side  effect; the slave shell ef-
  2895.      fectively runs in a  "subshell".  That is, any variables, func-
  2896.      tions, etc. set at the top level in the  master shell will also
  2897.      be seen by the  slave  shell.   Any  variables, etc. set by the
  2898.      slave  shell,  however will not be seen  by  the  master shell.
  2899.  
  2900.  
  2901.        SKsh Amiga Shell            Page 44                 User's Guide
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.      Usually this is not a  problem, and is worth this small cost in
  2912.      order  to  obtain rapid startup.  "Really  shared"  mode  saves
  2913.      about 25K per execution.
  2914.  
  2915.      Any SKsh started with the -s  or  -S  option which is the first
  2916.      one  running will still load the  sksh:sksh.msg  file  and  the
  2917.      initialization files.  Also shared  SKsh  sessions will set the
  2918.      "%" and  "$"  option flags.  Do not modify these by hand!  SKsh
  2919.      uses  them  internally to figure out which data is allocated by
  2920.      which  shell,  and  modifying these flags can  have  disastrous
  2921.      effects.
  2922.  
  2923.      One  potential  confusing  point  regarding "very shared"  mode
  2924.      should be  noted.   The  functions which list the contents of a
  2925.      symbol table (such as  the  "set"  command and the "alias" com-
  2926.      mand)   usually   list   the   contents  of  the  most   recent
  2927.      environment.  Since "very shared" mode pushes  a  new  environ-
  2928.      ment onto the stack, none of the  normal aliases, functions, or
  2929.      variables  present  in  the  parent environment will be listed.
  2930.      This can be worked around  by  using the new "-t" option to the
  2931.      "set"  or  "alias"  commands, which tells them to list the con-
  2932.      tents of the top-most  symbol table.  If your .skshrc file sets
  2933.      up,  for  example, an alias, but you don't see it when you type
  2934.      "aliases"  into  a  "really shared"  SKsh  window, this is why.
  2935.      Use the "aliases -t" command instead.
  2936.  
  2937.      One  important  note  is  that  you  CANNOT run both  SKsh  and
  2938.      Tiny_SKsh at the same time, due to the way in which they  share
  2939.      data.  Pick one or the other.
  2940.  
  2941.  
  2942.  
  2943.  
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.  
  2967.        SKsh Amiga Shell            Page 45                 User's Guide
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.  
  2975.  
  2976.  
  2977.        Advanced Topics: Changing the SKsh Message File
  2978.  
  2979.      The text of SKsh  error, help, and usage messages is now stored
  2980.      in a file and loaded at run time.  This  allows the messages to
  2981.      be customized.  The file will only be read by  the  first  SKsh
  2982.      invoked (see "Shared SKsh modes" above).
  2983.  
  2984.      The  message  catalog contains several main sections, which may
  2985.      come in any order.  The sections are as follows:
  2986.  
  2987.         USAGE:    This  section  contains  the  "usage" strings  for
  2988.                   each  SKsh  builtin command.  It  is  indicated by
  2989.                   the word  "USAGE:" in the message file, which must
  2990.                   be typed exactly as shown, with the colon.
  2991.  
  2992.         ERROR:    This  section  contains error code strings.  It is
  2993.                   prefixed by the word "ERROR:".
  2994.  
  2995.         HELP:     This  section contains the "help" strings for each
  2996.                   SKsh  builtin command.  It is prefixed by the word
  2997.                   "HELP:".
  2998.  
  2999.         VARS:     This  section  contains  default  variable assign-
  3000.                   ments  made  during SKsh  startup.   This  section
  3001.                   should not be customized.  Set up your  own  vari-
  3002.                   ables in your .skshrc file instead.
  3003.  
  3004.         ALIASES:  This  section contains default aliases set up dur-
  3005.                   ing SKsh  startup.   Like  the  VARS:  section, it
  3006.                   should not be customized.  Aliases should  be  set
  3007.                   up in your .skshrc file.
  3008.  
  3009.      At this point it may be  useful to examine the actual SKsh mes-
  3010.      sage  catalog file.   After the "USAGE:" keyword is a blankline
  3011.      which  is  both  optional and ignored.  The, the  usage strings
  3012.      for each  command, each separated by a "%" on a line by itself.
  3013.      Each  usage string must begin with the command name followed by
  3014.      a space  or  newline,  but  may  contain any number of lines of
  3015.      text.  Here is an example extracted from the message file:
  3016.  
  3017.         set [ -fabvs ] [ pattern ... ]
  3018.         %
  3019.         setmap -r
  3020.                setmap -s map [{key|code} {fn|"@map"|"!macro"}]...
  3021.                setmap -n mapnum ...
  3022.                setmap -e exitmap mapnum ...
  3023.                setmap -m macronum [ fn | string ] ...
  3024.         %
  3025.         shift [ num ]
  3026.         %
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.        SKsh Amiga Shell            Page 46                 User's Guide
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.      The  usage strings may come in any order, since SKsh will match
  3044.      them to the  appropriate command based on the first word in the
  3045.      usage message.  Note that the  "setmap" entry usage message has
  3046.      more than one line.  All but the first line are  indented; this
  3047.      makes the text line up when  SKsh  prints  the  "Usage:" before
  3048.      the first line of the message.
  3049.  
  3050.      At  the  end  of  the  "USAGE:"  section is a "%%" on a line by
  3051.      itself.  This must be  a  double  character to indicate the end
  3052.      of a section.
  3053.  
  3054.      The  format of the "HELP:"  section is exactly the same, except
  3055.      that SKsh will not print the first word in  the  message.   For
  3056.      example, consider:
  3057.  
  3058.         eval evaluate argument strings
  3059.         %
  3060.         exit leave sksh
  3061.         %
  3062.         export set value of an Amigados env: variable
  3063.         %
  3064.  
  3065.      When you type "help exit" in to a shell  window, SKsh will only
  3066.      print "leave sksh" as the help text,  not  "exit  leave  sksh".
  3067.      The  "HELP:"  section must  also  be  terminated by a "%%" on a
  3068.      line by itself.
  3069.  
  3070.      The  format  of  the  "ERROR:" section is slightly different in
  3071.      that  order  matters.   The   error  messages are listed, again
  3072.      separated by "%".  The first listed  error will become the text
  3073.      for  error 0, the second listed error for error 1, etc.  If you
  3074.      switch  two  error  messages, the text will be printed for  the
  3075.      incorrect error.  You can check the "ErrorCodes.doc"  file  for
  3076.      the  numbers of all the SKsh  error codes.  Again, the "ERROR:"
  3077.      section must be terminated by "%%" on a line by itself.
  3078.  
  3079.      The VARS:  and  ALIASES:  sections are in the same format.  The
  3080.      first word  of  each  line  is  the  variable or alias name.  A
  3081.      single space  after the name is ignored, and everything else is
  3082.      the  definition.    Variables can use the  values of previously
  3083.      set up variables.  Note  that  leading spaces (after the first)
  3084.      and  trailing spaces  are  maintained and assigned to the vari-
  3085.      able or alias.   For  example, see the "IFS" variable.  Assign-
  3086.      ments  may  use  the  normal ^ and \ escape mechanisms.  As you
  3087.      might expect, both the VARS:  and  ALIASES:  sections  must  be
  3088.      terminated by "%%".
  3089.  
  3090.      Neither VARS: nor ALIASES: should be customized.   Rather,  set
  3091.      up user  configuration data in your .skshrc file.  This data is
  3092.      present  in  the  message file simply to increase the amount of
  3093.      data which may be shared between SKsh invocations.
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.        SKsh Amiga Shell            Page 47                 User's Guide
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.  
  3107.  
  3108.  
  3109.      The sksh.msg  file  MUST  reside in the sksh: directory, and it
  3110.      will only be loaded into memory for the first SKsh  run.   This
  3111.      means that if you modify the file, your  changes  will  not  be
  3112.      seen until all shells exit and a new one is started.
  3113.  
  3114.      Since I am likely to add  new  error codes and builtin commands
  3115.      in  the  future, any  customizations you make to this file will
  3116.      have to be folded into  the  new  file  manually.   Other  than
  3117.      that, you are free to  customize this file as long as the over-
  3118.      all format remains valid.
  3119.  
  3120.  
  3121.  
  3122.  
  3123.  
  3124.  
  3125.  
  3126.  
  3127.  
  3128.  
  3129.  
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.  
  3136.  
  3137.  
  3138.  
  3139.  
  3140.  
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.        SKsh Amiga Shell            Page 48                 User's Guide
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.        Advanced Topics: Definable Keyboard Editing
  3176.  
  3177.      SKsh 1.5 and  later  provide a method to customize the keyboard
  3178.      editing  commands and emulate the editing style of most popular
  3179.      editors such as emacs and vi.
  3180.  
  3181.      A  keymap is a 256 byte  vector, each element of which can con-
  3182.      tain one of three things:
  3183.  
  3184.         * a function to be invoked when that key is pressed
  3185.         * a pointer to another keymap
  3186.         * a macro
  3187.  
  3188.      Currently,  approximately 35 functions are available and can be
  3189.      bound to and  key  or  key  combination.   These  functions are
  3190.      listed in the Reference.doc  entry for the setmap command.  All
  3191.      functions  have  a  2  or  3  character name descriptive of the
  3192.      function; for  example, "DEL" is used to delete a character and
  3193.      "EOL" is used to move the cursor to the end of the line.
  3194.  
  3195.      As  a  simple  example  of  defining our own editing sequences,
  3196.      follow along with the  examples provided here.  You may wish to
  3197.      "more" this file in one window (or print it out) and  run  SKsh
  3198.      in another window so you can  try  the  examples  as  they  are
  3199.      presented.   All   keymapping is done with the  setmap command.
  3200.      The  first  form  of  the  setmap  command is used to reset all
  3201.      keymaps to their "dumb" state:
  3202.  
  3203.         [dh0:]: setmap -r
  3204.  
  3205.      After this  command, none of the SKsh keyboard editing commands
  3206.      will work; even arrow keys will be disabled.  We can now  start
  3207.      defining our own.  Keymaps  have  numbers; the "root" keymap is
  3208.      numbered 0, and  others are available (for the exact limit, see
  3209.      the  setmap  entry in the Reference.doc file).   For  starters,
  3210.      let  us  enable the backspace key, the delete key, and ^a to be
  3211.      beginning of line.  The  first  parameter to the setmap command
  3212.      is  the   keymap  number;  after  that,  it  accepts  pairs  of
  3213.      parameters. The first  member of each pair is the ASCII code or
  3214.      letter to map,  and  the  second is the function itself.  Since
  3215.      we know  that  the  backspace key sends an ASCII code of 8, the
  3216.      delete key sends an ASCII code of 127, and ^a  sends  an  ASCII
  3217.      code of 1:
  3218.  
  3219.         [dh0:]: setmap 0   8 BS   127 DEL  1 BOL
  3220.  
  3221.      (Here  extra spaces have been inserted for clarity).  Make sure
  3222.      you don't  make  any  mistakes when typing that line, since the
  3223.      backspace key does  not  yet  work!   The  backspace and delete
  3224.      keys should  now  work  as  expected after the line is entered.
  3225.      Verify  this  by  typing some text, using ^a to move to the be-
  3226.      ginning of  the  line,  and  using the delete key to delete the
  3227.      characters.  The BS and DEL  key  functions can be swapped with
  3228.      the following line:
  3229.  
  3230.  
  3231.        SKsh Amiga Shell            Page 49                 User's Guide
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.  
  3239.  
  3240.  
  3241.  
  3242.         [dh0:]: setmap 0   8 DEL  127 BS
  3243.  
  3244.      Type that to verify that the  backspace key now deletes and the
  3245.      delete key now backspaces.  Then switch them back.  Just a  re-
  3246.      minder  that  you  cannot  recall the previous command with the
  3247.      arrow keys, since we don't have them mapped yet.
  3248.  
  3249.      Next, we will map some  multiple  key  sequences.   Perhaps  we
  3250.      wish to make a series of two character keymappings as follows:
  3251.  
  3252.         ~u  = move to previous history line
  3253.         ~d  = move to next history line
  3254.         ~c  = perform filename completion
  3255.         ~~  = insert a '~' character
  3256.  
  3257.      These are not part  of  the  normal keybindings, but we can use
  3258.      them for  demonstration purposes.  First it is necessary to re-
  3259.      alize that if we wish to map the '~' key plus other  characters
  3260.      to some  functions, we have to use two keymaps.  The first key-
  3261.      map will map the '~' key to call  the  second keymap.  The sec-
  3262.      ond  keymap will map "u" to call the "UP" function, "d" to call
  3263.      the  down  function, etc.  First,  in  keymap number 0, map the
  3264.      '~' key to call keymap number 1:
  3265.  
  3266.         [dh0:]: setmap 0  '~' @1
  3267.  
  3268.      Now map the 'u',  'd',  'c',  and  '~'  keys  appropriately  in
  3269.      keymap number 1:
  3270.  
  3271.         [dh0:]: setmap 1  'u' UP  'd' DN  'c' CC1  126 INS
  3272.  
  3273.      Now type a few lines into  the  history buffer (perhaps comment
  3274.      lines), and  verify  that  pressing the '~' key followed by 'u'
  3275.      will  move  to  the  previous line, '~d' will move to the  next
  3276.      line, '~c'  will  perform file completion, and '~~' will insert
  3277.      a single '~'  character.   Note  that  in  the  second line, we
  3278.      needed to use the ASCII  code  of  126  instead of '~' since in
  3279.      the first line we mapped '~' to  call  the  second keymap.  Be-
  3280.      fore the  second keymap was defined, however, we cannot use the
  3281.      '~' key!   The  mapping to the "INS" commands tells SKsh to in-
  3282.      sert the last typed character.  This is  in  fact  the  default
  3283.      keybinding for most keys in a keymap unless they are changed.
  3284.  
  3285.      We could  map  the  arrow keys in the same manner, but for this
  3286.      demo that is not necessary.  All that  is  needed  is  to  know
  3287.      which ASCII  sequences the arrow keys send; for example, the up
  3288.      arrow sends  an  ASCII  155  followed by the character 'A'.  In
  3289.      keymap 0 we would set the ASCII  155  character to call another
  3290.      keymap, and  in  that  keymap 'A' would call the 'UP' function,
  3291.      'B' would call DN, 'C' would call LFT, and 'D' would call RHT.
  3292.      In  a  similar manner, any three or four character sequence can
  3293.      also be mapped.
  3294.  
  3295.  
  3296.  
  3297.        SKsh Amiga Shell            Page 50                 User's Guide
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.  
  3305.  
  3306.  
  3307.      Macros  may  be  defined and bound to keys.   These  macros are
  3308.      dumb;  they  contain no logic.   Macros can insert text or call
  3309.      functions.    Perhaps we wish to make a macro which,  when  ex-
  3310.      ecuted, moves  to  the  beginning of the line, inserts the text
  3311.      '#boo#', then moves to the end of  the  line,  inserts the next
  3312.      '#who#',  and  "accepts" the line as if we had pressed  return.
  3313.      Macros  are  numbered; for information on the maximum number of
  3314.      macros and maximum length of a macro, see  the  setmap entry of
  3315.      the Reference.doc file.   The  setmap -m command is used to de-
  3316.      fine macros.  We will define macro number 0:
  3317.  
  3318.         [dh0:]: setmap -m 0  BOL '#boo#' EOL '#who#' ACC
  3319.  
  3320.      Now we need to map our macro to a key.  Let us map  it  to  the
  3321.      '~#' key combination.  We already have a keymap for '~', so:
  3322.  
  3323.         [dh0:]: setmap 1 '#' '!0'
  3324.  
  3325.      The  '!0'  sequence  tells  setmap to call macro 0.  It must be
  3326.      quoted;  otherwise  the  shell  interprets  it  as  a  wildcard
  3327.      pattern.  Verify our  new  macro  by  typing "echo HI" at a new
  3328.      command line and  then  typing the '~#' combination.  The macro
  3329.      should do as we expect.  Let us now make  a  macro  to  extract
  3330.      the   previous  line  from  the  history  list  beginning  with
  3331.      '#boo#', remove the '#boo#' and '#who#' and execute the line:
  3332.  
  3333.         [dh0:]: setmap -m 1 BOL KEL '#boo#' SRH BOL DEL DLW DEL \
  3334.            EOL BS BDW BS ACC
  3335.         [dh0:]: setmap 1 '!' '!1'
  3336.  
  3337.      As you can see, we  have  bound  our  new  macro  to  the  '~!'
  3338.      combination.  Also, the '\' at the end of the first line  tells
  3339.      SKsh  to  pretend the next line is a continuation of the first.
  3340.      You could type all this on one line; I just did it that way  to
  3341.      easily fit in across this page.  If you need to know  what  the
  3342.      functions  do,  remember  to  refer to the Reference.doc  file.
  3343.      Now,  assuming the "echo HI" line  with  the  extra '#boo#' and
  3344.      '#who#' is still in  our  history list, type '~!' and this line
  3345.      will be searched  for  (by  finding the '#boo#'), the two words
  3346.      will be removed, and this command will be executed.
  3347.  
  3348.      Mode  as  well  as  modeless  editors can be emulated.  For ex-
  3349.      ample,  perhaps we wish to make  a  "movement" mode such as the
  3350.      one used in "vi".  We can map the ESC key  to  enter this mode,
  3351.      but  normally the first key  pressed  will  exit  back  to  the
  3352.      "root"  keymap (0).  We can get around this  by  making our new
  3353.      keymap a "non-exiting" keymap with the setmap -n command:
  3354.  
  3355.         [dh0:]: setmap 0  27 @2
  3356.         [dh0:]: setmap -n 2
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.        SKsh Amiga Shell            Page 51                 User's Guide
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.      Now, we can  define the 'h', 'j', 'k', and 'l' keys to move the
  3374.      cursor.  We will also have to have a way to  get  back  to  our
  3375.      root  keymap; for this  example we will just define the ESC key
  3376.      to do this (ie, it will toggle between the two modes):
  3377.  
  3378.         [dh0:]: setmap 2 'h' LFT 'j' DN 'k' UP 'l' RHT 27 @0
  3379.  
  3380.      Now  type  some  characters, press ESC, and verify that the new
  3381.      keys move around as expected.  Don't press  return in the mode,
  3382.      since we haven't mapped it to anything.   Press  ESC  again  to
  3383.      get back into "insert" mode again.
  3384.  
  3385.      Keymaps can also be made to  exit  to  a  specific keymap other
  3386.      than  the  root  keymap (which is the  default).  The setmap -e
  3387.      command accomplishes this.  No example will be give here.
  3388.  
  3389.      Keymaps take 256 of memory each.  After a  "setmap -r" command,
  3390.      all keymaps except keymap 0 are freed.  Keymaps  are  allocated
  3391.      when any reference to them  is  made.   The  same  applies  for
  3392.      macros.
  3393.  
  3394.      The  above  simple  examples have covered most of the capabili-
  3395.      ties of the  setmap command.  Two functions are provided in the
  3396.      Stuff.sksh  file  which   define  emacs  and  vi  modes.    The
  3397.      .skshinit  file  also  defines an emacs  mode  as  the  default
  3398.      behavior.  See  these  functions for a better example of making
  3399.      a  working  editing  mode.   The  setmap command should provide
  3400.      enough  functionality  to  customize your SKsh keyboard editing
  3401.      commands as desired.
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.        SKsh Amiga Shell            Page 52                 User's Guide
  3430.  
  3431.  
  3432.  
  3433.