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

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.                                    User's Guide to
  17.  
  18.                                          ASH
  19.  
  20.                            A ksh-like Shell for the Amiga
  21.  
  22.                                      Version 1.0
  23.  
  24.  
  25.                                   (Copyright) 1989 
  26.  
  27.                                      Steve Koren
  28.  
  29.                                   November 7, 1989
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.           Table of Contents
  74.  
  75.                Introduction......................................3
  76.                Copyright Notice and Other Legal Stuff............4
  77.                A Brief History of Unix Shells....................5
  78.                Ash Syntax........................................6
  79.                Credits...........................................8
  80.                What Ash is and is Not............................9
  81.                The Rest of this Document.........................9
  82.                Ash Basics: Executing Commands....................10
  83.                Ash Basics: I/O Redirection.......................11
  84.                Ash Basics: Pipe Lines............................12
  85.                Ash Basics: Strings and Variables.................13
  86.                Ash Basics: Parameter Substitution................15
  87.                Ash Basics: Wildcards.............................16
  88.                Using Ash Aliases.................................17
  89.                Using Ash Functions...............................18
  90.                Function, Alias, Builtin Priority.................20
  91.                Ash Command Substitution..........................21
  92.                Control Structures: if-then-elif-else-fi..........23
  93.                Control Structures: while-do-done.................24
  94.                Control Structures: for-do-done...................25
  95.                Test Expressions..................................26
  96.                Sub-Shell Execution...............................28
  97.                File Name Mapping.................................29
  98.                Ash Scripts.......................................30
  99.                Command Line Editing and History..................31
  100.                Filename Completion...............................34
  101.                Index to Users's Guide............................36
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.           ASH Amiga Shell               Page 2                User's Guide
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.           Introduction
  140.  
  141.             Ash (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.  Ash  provides
  145.             a very powerful environment; however,  it  is  not  for  casual
  146.             workbench users who want a "point and click" interface.
  147.  
  148.             Ash 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.                  *  I/O redirection and pipes
  165.  
  166.                  *  A large variety of built-in commands
  167.  
  168.                  *  Unix style wildcards
  169.  
  170.                  *  Unix filename conventions in AmigaDos (such as  ../file
  171.                     or ~/file)
  172.  
  173.                  *  Filename completion using <esc><esc> or tab
  174.  
  175.                  *  Coexistence with scripts from other shells
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.           1_____________________Unix is a trademark of AT&T.
  192.  
  193.  
  194.  
  195.           ASH 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 Steve Koren.  It is not  public
  208.             domain; however, it is freely distributable, provided  that  it
  209.             is not sold for profit  without  the  written  consent  of  the
  210.             author.  It may be included in compilations  of  public  domain
  211.             software, freely distributable software, and shareware  without
  212.             written consent of the author provided that no more than  $7.00
  213.             US 1989 dollars are charged for distribution and disk  handling
  214.             overhead.
  215.  
  216.             This and all included documents and works  are  also  copyright
  217.             1989 Steve Koren, and are included in the terms  of  the  above
  218.             paragraph.
  219.  
  220.             Any code included with this software may  be  freely  modified.
  221.             However, further distribution  of  this  modified  software  is
  222.             restricted  to  the  condition  that  a  notice  of  the  exact
  223.             modifications be clearly included with the documentation.   The
  224.             existing documentation may not be modified, only  appended  to.
  225.             The sole exception to this rule is that the  documentation  may
  226.             be translated to other languages and the original omitted.
  227.  
  228.             The porting of  this  software  to  other  computers  than  the
  229.             Commodore Amiga is permitted.
  230.  
  231.             The author of this software does  not  not  officially  support
  232.             it.  It is provided in the hope that it  will  be  useful,  but
  233.             since it is free, no guarantees of any kind are  provided,  and
  234.             you, the user, accept responsibility for its use.
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.           ASH 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
  274.             provides a programmable shell, and it is favored by  some  Unix
  275.             users because it also provides limited mechanisms  for  history
  276.             and command editing.   This  editing  is  cumbersome,  however,
  277.             using notations like this:
  278.  
  279.                   % ^echo^ls -l
  280.  
  281.             to edit lines.
  282.  
  283.             sh  provides  a  more  powerful   and   intuitive   programming
  284.             environment  than  csh, so it is preferred for writing scripts.
  285.             However, 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 shell.   It  provides  much  better  editing  and  history
  289.             mechanisms  than   csh,  and  a  more  powerful,  but  upwardly
  290.             compatible  programming environment than  sh.  This, it has the
  291.             advantages of both shells.
  292.  
  293.             Ash on the Amiga is patterned closely  after  ksh, although ksh
  294.             provides a much more powerful environment than does Ash.
  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.           ASH Amiga Shell               Page 5                User's Guide
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.           Ash Syntax
  338.  
  339.             If  you  are  familiar  with  ksh or  sh programming under Unix
  340.             (tm), you will almost immediately  become  proficient  at  Ash.
  341.             Although  Ash  scripts  are  not  compatible  (except  in  some
  342.             specific cases) with those  of  sh or ksh, the syntax is nearly
  343.             identical, and many of the  same  commands  are  present.   Ash
  344.             operation will be discussed in much greater detail  later,  but
  345.             some examples are presented here,  mainly  for  those  who  are
  346.             already 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
  355.                control 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
  367.                structures or sub-shells separated by pipe symbols.  A  pipe
  368.                symbol is a vertical bar ('|').  For example, the  following
  369.                is 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
  381.                structures, pipes,  or  other  sub-shells.   Sub-shells  are
  382.                delimited 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.           ASH Amiga Shell               Page 6                User's Guide
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.                above differ in their behaviour; 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
  420.                accessed much faster  than  a  script.   Here  is  a  sample
  421.                function 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
  430.                commands 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
  436.                example,
  437.  
  438.                  alias hist = '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.           ASH Amiga Shell               Page 7                User's Guide
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.           Credits
  471.  
  472.             Ash was developed on and for the Commodore Amiga.
  473.  
  474.             Ash was implemented and debugged entirely with  Lattice C 5.02.
  475.             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.             Ash was written and 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! by MSS.  It did all
  485.             the cool stuff like the table of contents and index.
  486.  
  487.             Ash is freely distributable.
  488.  
  489.             The Ash 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 Ash grammar.   I
  492.             had expected to have problems with a micro based  yacc,  but  I
  493.             had none at all.
  494.  
  495.             Until Ash was usable, I used Matt Dillon's shell version  3.01A
  496.             during Ash development.  I like that shell far better than  the
  497.             normal AmigaDos environment.   It  provides  "real"  wildcards,
  498.             and many other neat  things  the  normal  AmigaDos  environment
  499.             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.             Ash uses ARP for command execution.  There was no other  simple
  507.             way to do it.
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.           ASH Amiga Shell               Page 8                User's Guide
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.           What Ash is and is Not
  536.  
  537.             Ash is a powerful alternative  to  the  normal  Amigados  shell
  538.             environment.  This power comes at a  price,  however.   Ash  is
  539.             not a tiny program.  Ash is currently about 70 K  bytes;  small
  540.             by Unix standards but quite large for AmigaDos.
  541.  
  542.             Ash provides a very similar environment  to  that  found  under
  543.             the two Unix shells mentioned above.   It  does  not  claim  or
  544.             attempt to  provide  an  identical  environment.   Some  simple
  545.             scripts will run under Ash or ksh, but this fact should not  be
  546.             depended on.  In many cases, ksh  provides  features  that  Ash
  547.             does not.  In some cases, Ash provides features that  ksh  does
  548.             not.  Ash  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.             Ash 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 Ash does.  The  Ash
  555.             script language is adequately fast for simple tasks, but it  is
  556.             not suitable for complex calculations or algorithms.
  557.  
  558.             Ash  is  freely  distributable  software.   It  is  not  public
  559.             domain.   No  one  else  may  sell  Ash  without   my   written
  560.             permission, except in  the  cases  detailed  in  the  copyright
  561.             notice.  You are, however,  encouraged  to  distribute  Ash  as
  562.             widely as possible.  It is completely free;  however,  with  my
  563.             other free software package (QRT, a  ray  tracer)  some  people
  564.             sent money anyway.  Any money I do receive  from  Ash  will  be
  565.             used for repair, maintenance, and upgrade of my  2000,  and  to
  566.             purchase upgrades 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 Ash.  It assumes  that  you  are  familiar  with  the
  573.             basic concept and operation of a  command  interface,  such  as
  574.             the AmigaDos CLI.  If you  are  already  a  user  of  sh or ksh
  575.             under Unix, you will  probably  be  able  to  go  through  this
  576.             document very quickly.   I  do  recommend  that  you  read  it,
  577.             though, to see what Ash does and does not do, and to  see  what
  578.             differences there are between Ash and the Unix shells.
  579.  
  580.             The Ash reference  manual  explains  each  command  in  greater
  581.             detail, although more concisely.  This document does  not  even
  582.             come close to covering every Ash command.  It is mean  to  give
  583.             you an understanding of the Ash environment, so  that  you  can
  584.             examine  the  reference  manual  for  information  on  specific
  585.             commands.
  586.  
  587.  
  588.  
  589.  
  590.  
  591.           ASH Amiga Shell               Page 9                User's Guide
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.           Ash Basics: Executing Commands
  602.  
  603.             Ash can, at the most simple level, be used  like  the  AmigaDos
  604.             shell.  Ash 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 Ash.
  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
  624.             familiar with the 'emacs' editor from FSF, Ash duplicates  some
  625.             of those keybindings.
  626.  
  627.             In Ash, pressing control followed by 'c'  (^c)  will  generally
  628.             abort whatever Ash is currently doing and  return  you  to  the
  629.             Ash prompt.  For example, if you type 'sleep  6000',  Ash  will
  630.             wait for a very long time before returning to the prompt.   You
  631.             can press ^c to abort this command.  However, if  an  external,
  632.             non-Ash command is executing,  that  command  may  or  may  not
  633.             listen to ^c.
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.           ASH Amiga Shell              Page 10                User's Guide
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.           Ash 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
  677.             example, the following are all equally valid:
  678.  
  679.                c:status > outfile
  680.  
  681.                ash_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  Ash  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.           ASH Amiga Shell              Page 11                User's Guide
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.           Ash Basics: Pipe Lines
  734.  
  735.             A pipe line 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 Ash 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.             Ash 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.
  770.             Therefore, the first release of Ash  uses  temporary  files  in
  771.             the pipe-line instead of true  inter-process  pipes  using  the
  772.             pipe: device.  Temporary file pipes are not  nearly  as  useful
  773.             as interprocess pipes; they are slower, and are limited by  the
  774.             free space on the device used to hold the files.   However,  at
  775.             the moment, the capability I  need  to  implement  interprocess
  776.             pipes is simply not there in a useable manner.  If  the  needed
  777.             capability ever shows up on the Amiga, Ash is written  to  take
  778.             advantage 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 Ash '|' pipe notation.
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.           ASH Amiga Shell              Page 12                User's Guide
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.           Ash Basics: Strings and Variables
  800.  
  801.             Strings and variables are basic to the operation  of  Ash.   A  
  802.             string  is  simply  a  sequence  of   non-special   characters,
  803.             optionally  surrounded  by  single  or  double   quotes.    For
  804.             example, this 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  variable in Ash is simply a storage place for strings.   Any
  841.             number of variables can be created.  Variables can be  assigned
  842.             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
  848.             assignment operator, is legal in Ash,  but  not  in  sh or ksh.
  849.             The Ash assignment operator is upward compatible with the  Unix
  850.             shells.
  851.  
  852.             Variables can be retrieved by prefixing the variable name  with
  853.  
  854.  
  855.           ASH 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.             would not display the contents  of  the  variable  my_var,  but
  887.             rather would display the actual string $my_var,  including  the
  888.             '$' 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
  900.             equivalent to big_var  =  `cat  my_file`,  which  may  be  more
  901.             familiar   to   sh  users,  but  the  first  example  above  is
  902.             recommended).
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.           ASH Amiga Shell              Page 14                User's Guide
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.           Ash Basics: Parameter Substitution
  932.  
  933.             Ash  normally  eliminates  white  space  (blanks,  newlines and 
  934.             tabs)  from  between  parameters  to  commands.   For  example,
  935.             notice 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  Ash  commands  can  have  any  number of  parameters,
  966.             (until you run out of memory).  External commands  are  limited
  967.             by the AmigaDos command  interpreter,  which  does  not  accept
  968.             commands 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.           ASH Amiga Shell              Page 15                User's Guide
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.           Ash Basics: Wildcards
  998.  
  999.             Ash 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.  
  1007.             Since wildcards are expanded by Ash, and  not  by  the  command
  1008.             itself as in AmigaDos, they  may  be  used  with  any command -
  1009.             even a command such as 'echo'  which  does  not  normally  deal
  1010.             with files (try echo *).
  1011.  
  1012.             Here are some  examples  using  the  first  two  special  types
  1013.             above:
  1014.  
  1015.                a*f       matches 'af', 'abf', 'aazzzewerf', etc.
  1016.                a?f       matches 'abf', 'acf', but not 'af' or 'aaaf'
  1017.  
  1018.             The square brackets  above  are  used  to  define  a  character
  1019.             class.  A character class is simply way to  specify  an  exact  
  1020.             set  of  characters.  Character classes may  contain  either  a
  1021.             series  of  enumerated  characters, a range of characters, or a
  1022.             negation of any of the above.  For example,
  1023.  
  1024.  
  1025.                [abcz]    matches the character a, b, c, or z.
  1026.                [a-cv-z]  matches either a, b, c, v, w, y, x, or z.
  1027.                [!a-d]    matches any character except a, b, c, or d.
  1028.  
  1029.             Character classes may be combined with the * and ? wildcards:
  1030.  
  1031.                [a-c]*.c  matches any file starting with  a,  b,  or  c  and
  1032.                          ending with '.c'
  1033.  
  1034.             Wildcards are only expended  as  normal  parameters;  that  is,
  1035.             outside of quoted strings of any  sort.   Wildcards  also  have
  1036.             certain other uses in Ash besides matching files (for  example,
  1037.             see the 'match' or 'set' commands).
  1038.  
  1039.             Wildcards  do  not  have  to  be  used  in  only  the  filename
  1040.             component of a path.  For example, all  of  the  following  are
  1041.             valid wildcard patterns:
  1042.  
  1043.                sys:*/Format
  1044.                sys:System/Fo*
  1045.                mydir/*/*.c
  1046.                *.[hc]
  1047.  
  1048.             Wildcards are currently case-sensitive.
  1049.  
  1050.             (See also: File name mapping)
  1051.  
  1052.  
  1053.           ASH Amiga Shell              Page 16                User's Guide
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.           Using Ash Aliases
  1064.  
  1065.             An  'alias' in Ash is simply a way to  save  typing  time.   An
  1066.             alias can stand for any series  of  characters.   For  example,
  1067.             perhaps you enjoy seeing the version number of Ash.  You  enjoy
  1068.             it so much, in fact, that you tire  of  typing  'version'  over
  1069.             and over.  You can define an alias,  called  'v',  that  simply
  1070.             stands for the 'version' command:
  1071.  
  1072.                [dh0:]: alias v=version
  1073.                [dh0:]: v
  1074.                     Ash Version 1.0, Copyright 1989 Steve Koren
  1075.  
  1076.             You can also include parameters  after  the  alias  call.   For
  1077.             example:
  1078.  
  1079.                [dh0:]: v -d
  1080.                     19:13:18 Oct 12 1989
  1081.  
  1082.             The alias command only looks at one  parameter  after  the  '='
  1083.             sign, so to include parameters in the alias, you  must  enclose
  1084.             the alias definition in quotes:
  1085.  
  1086.                [dh0:]: alias v='version -d'
  1087.                [dh0:]: v
  1088.                     19:13:18 Oct 12 1989
  1089.  
  1090.             To  obtain  a  list of aliases, simply use the alias command by
  1091.             itself:
  1092.  
  1093.                [dh0:]: alias
  1094.                     (big list of aliases)
  1095.  
  1096.             I left out the list of  aliases  above,  because  there  are  a
  1097.             large number supplied by Ash itself.  One  of  these  built  in
  1098.             aliases  is  the  unalias  command.   To  find  out  what   the
  1099.             definition of unalias is:
  1100.  
  1101.                [dh0:]: alias unalias
  1102.                     unalias      = unset -a
  1103.  
  1104.             So, the unalias command simply runs  the  command  'unset  -a'.
  1105.             Unalias is provided as a built in alias, however, since  it  is
  1106.             easier to remember than unset -a.  Unalias removes  any  number
  1107.             of alias definitions:
  1108.  
  1109.                [dh0:]: unalias v foo bar
  1110.  
  1111.             The above line would remove the alias definitions  of  v,  foo,
  1112.             and bar.
  1113.  
  1114.             Note that alias commands  may  be  used  just  like  any  other
  1115.             command, in scripts, functions, or substitution statements.
  1116.  
  1117.  
  1118.  
  1119.           ASH Amiga Shell              Page 17                User's Guide
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.           Using Ash Functions
  1130.  
  1131.             While aliases are limited to simple  text  substitution  uses,  
  1132.             functions are vastly more powerful.  Functions  provide  a  way
  1133.             to store Ash programs within Ash itself instead of in  a  file.
  1134.             Here is an example function that Ash loads when it  starts  up.
  1135.             Don't worry if you don't understand everything in the  function
  1136.             definition; it will  be  explained  later  in  the  programming
  1137.             sections.  For now, just notice that functions can contain  any
  1138.             Ash statements, and are delimited by curly braces:
  1139.  
  1140.                function path {   # set or examine path
  1141.                     local comp;
  1142.  
  1143.                     if [ $# -eq 0 ]
  1144.                     then
  1145.                       echo "$PATH"
  1146.                     elif [ "$1" = '-add' -o "$1" = 'add' ]
  1147.                     then
  1148.                       shift
  1149.  
  1150.                       for comp in $* do
  1151.                          if [ $( expr index "$PATH," "$comp," ) -eq 0 ]
  1152.                          then
  1153.                            PATH = "$PATH,$comp"
  1154.                          fi
  1155.                       done
  1156.                     else
  1157.                       PATH="$1"
  1158.                     fi
  1159.  
  1160.                     export PATH
  1161.                }
  1162.  
  1163.             That function is one that defines  a  "path"  command  in  Ash.
  1164.             Functions may be used like any other command.  You do not  even
  1165.             have to know that they are functions.  For example,  the  above
  1166.             command, with no parameters, simply prints the path.  This  can
  1167.             be output to a file, a follows:
  1168.  
  1169.                [dh0:]: path > my_file
  1170.  
  1171.             The path function could also be used in other functions.   This
  1172.             provides a very powerful mechanism for  extending Ash.  It will
  1173.             be particularly interesting for floppy users who  do  not  want
  1174.             to wait for slow script files.
  1175.  
  1176.             When Ash  functions  are  executed,  several  important  things
  1177.             happen.  All variables, functions, and aliases  defined  inside
  1178.             the  function  are   local  to  that  function  (although  this
  1179.             behaviour is changeable  in  several  ways  -  see  the  option
  1180.             command).  Hence:
  1181.  
  1182.  
  1183.  
  1184.  
  1185.           ASH Amiga Shell              Page 18                User's Guide
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.                function outer {
  1196.                   function inner {
  1197.                      echo "my first parameter is $1"
  1198.                   }
  1199.                   inner $1
  1200.                }
  1201.  
  1202.             The  function  named  'inner'  can  only  be  used  within  the
  1203.             function named 'outer'.  You will notice also that  a  variable
  1204.             called $1 is  referenced,  but  not  set.   There  are  several
  1205.             variables that are automatically set by  Ash  when  a  function
  1206.             (or script) is invoked.  The most  useful  are  $0, $1, $2, $3,
  1207.             etc.  They are set to the  parameters passed into the function.
  1208.             Note that $0 is set to the function name itself:
  1209.  
  1210.                [dh0:]: function test1 {
  1211.                >    echo "0 = $0, 1 = $1, 2 = $2"
  1212.                > }
  1213.  
  1214.                [dh0:]: test1 foo bar
  1215.                     0 = test1, 1= foo, 2 = bar
  1216.  
  1217.             Also note the ">" marks to the left of the 2nd  and  3rd  lines
  1218.             of the function.   They  are  the  secondary Ash prompt string,
  1219.             used when it expects more input.  You shouldn't type them.
  1220.  
  1221.             Ash also  sets  the  variable  '$#' to the number of parameters
  1222.             passed into the function:
  1223.  
  1224.                [dh0:]: function countp { echo "Number = $#" }
  1225.                [dh0:]: countp "this is all one" another param
  1226.                     Number = 3
  1227.  
  1228.             The  variable  '$*' is set to the  entire  parameter list.  For
  1229.             example:
  1230.  
  1231.  
  1232.                [dh0:]: function pparams { echo "Args = $*" }
  1233.                [dh0:]: pparams foo bar not
  1234.                     Args = foo bar not
  1235.  
  1236.             These standard variables  can  be  modified  with  the  'shift'
  1237.             command - see the documentation on that command for details.
  1238.  
  1239.             Any functions or aliases used within a  function  will  operate
  1240.             correctly even if they are defined after the  function  itself.
  1241.             (That is, they are bound dynamically  at  run-time).   This  is
  1242.             different than the ksh behavior.
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.           ASH Amiga Shell              Page 19                User's Guide
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.           Function, Alias, Builtin Priority
  1262.  
  1263.             In Ash, you can define a function or alias that  overrides  the
  1264.             definition of a an  Ash  builtin  command  (such  as  the  echo
  1265.             statement).  Ash will evaluate a function definition before  an
  1266.             alias with the same name, and an alias before  a  builtin  with
  1267.             the same  name.   Thus,  you  can  redefine  the  internal  ash
  1268.             commands.
  1269.  
  1270.             Ash still provides a mechanism to access the builtin  commands,
  1271.             even though you might have redefined them.   The  force keyword
  1272.             can  be  used  to  force the execution of a command as either a
  1273.             function, an alias, or a builtin.  For example,  say  you  have
  1274.             redefined the ash date command with a function, as follows:
  1275.  
  1276.                [dh0:]: function date {
  1277.                >    echo 'The date command is not available today.'
  1278.                >    }
  1279.  
  1280.             Any future calls to the date command will  have  the  following
  1281.             result:
  1282.  
  1283.                [dh0:]: date
  1284.                     The date command is not available today.
  1285.  
  1286.             Suppose, however, that  you  really did wish to access the date
  1287.             builtin command, and not your function.  Use the  force keyword
  1288.             with the -b options (for force execution as a builtin):
  1289.  
  1290.                [dh0:]: force -b date
  1291.                     Sat Oct 14 11:13:27 1989
  1292.  
  1293.             This can be particularly  useful  when  you  wish  to  use  the
  1294.             original date command inside of your own.  Perhaps you wish  to
  1295.             define a date command which prints "The year is:"  followed  by
  1296.             the current year:
  1297.  
  1298.                [dh0:]: function date {
  1299.                >    echo -n 'The year is: '; force -b date -y
  1300.                >    }
  1301.                [dh0:]: date
  1302.                     The years is: 1989
  1303.  
  1304.             In this case, the force -b command must be used to  access  the
  1305.             builtin date command.   If  it  was  left  out,  the  new  date
  1306.             function would be used  instead,  calling  itself  recursively.
  1307.             Ash would eventually detect this situation and issue  an  error
  1308.             message, but it is not what the command was intended to do.
  1309.  
  1310.             The force keyword also accepts -f and -a parameters,  to  force
  1311.             execution as a function or alias.
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.           ASH Amiga Shell              Page 20                User's Guide
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.           Ash Command Substitution
  1328.  
  1329.             Ash provides several mechanisms for capturing the output  of  a
  1330.             statement for subsequent use.  The preferred method is  to  use
  1331.             the following syntax:
  1332.  
  1333.                $(command)
  1334.  
  1335.             Ash will insert the output of the command as if  it  was  typed
  1336.             in the  Ash  command  line.   Consider  an  example.   The  ash
  1337.             function 'basename' prints the file name part of a  path  name.
  1338.             For example,
  1339.  
  1340.                [dh0:]: basename sys:path/to/my/file
  1341.                     file
  1342.  
  1343.             Now, suppose you wish to obtain the file part of a path  string
  1344.             for use in an ash function.  Normally the  'basename'  function
  1345.             copies the data to the screen.   You  want  to  have  it  in  a
  1346.             variable.  If the path you're interested in is in the  variable
  1347.             my_path:
  1348.  
  1349.                [dh0:]: bn = $(basename $my_path)
  1350.  
  1351.             The  variable  'bn'  will  contain  the  desired   information.
  1352.             Parameter substitution may be  nested.   For  example,  perhaps
  1353.             you wish to  obtain  the  length  in  characters  of  the  file
  1354.             portion of the path name:
  1355.  
  1356.                [dh0:]: len = $(expr length $(basename $my_path) )
  1357.  
  1358.             The  alternative  syntax  for   command   substitution   uses   
  1359.             backticks:
  1360.  
  1361.                [dh0:]: len = `basename $my_path`
  1362.  
  1363.             However, the first  notation  is  preferred  for  a  number  of
  1364.             reasons.  Using the backtick notation,  Ash  reads  the  entire
  1365.             substitution  command  as  one  token, or  set  of  characters.
  1366.             Tokens in Ash are limited by  the  parser  to  1024  characters
  1367.             (although strings and variables can be  of  any  length).   The
  1368.             parenthetical  notation  for  command   substitution   has   no
  1369.             restrictions on the length of the command enclosed -  it  could
  1370.             be an entire ash program.  Also, the parenthetical notation  is
  1371.             faster than the backtick notation.
  1372.  
  1373.             You will discover that command substitution is  a  very  useful
  1374.             thing to have around.  One of  the  more  common  uses  is  the
  1375.             following:
  1376.  
  1377.                [dh0:]: my_program $(which abc)
  1378.  
  1379.             Here, my_program is a  program  which  uses  abc  in  some  way
  1380.             (perhaps executes it or edits it).  'abc' is  known  to  be  in
  1381.  
  1382.  
  1383.           ASH Amiga Shell              Page 21                User's Guide
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.             your Ash path, but my_program does not know  about  Ash  paths.
  1394.             The  which function in Ash prints the full path name of a  file
  1395.             in the search path, so the above command saves you from  having
  1396.             to remember and type the full path.
  1397.  
  1398.             Command  substitution  works  with  any  Ash  statement.    For
  1399.             example:
  1400.  
  1401.                [dh0:]: a = $( for a in a b c
  1402.                >              do
  1403.                >                 echo "a: $a"
  1404.                >              done )
  1405.  
  1406.                [dh0:]: echo "$a"
  1407.                     a: a
  1408.                     a: b
  1409.                     a: c
  1410.  
  1411.             Note that the same variable was used both  inside  and  outside
  1412.             the command substitution.  This  is  ok,  since  the  statement
  1413.             list  inside  the  command  substitution  marks  is  completely
  1414.             evaluated before the assignment is made.
  1415.  
  1416.             Command substitution can also be used with  external  commands.
  1417.             Since external binaries do  not  support  command  substitution
  1418.             directly, Ash stores the results in a  temporary  file  in  the
  1419.             't:' directory.   When  finished,  Ash  deletes  the  temporary
  1420.             file.  't:' should be assigned to a fast device, such as a  ram
  1421.             disk.  Actually, a subdirectory on the ram  disk  is  best,  so
  1422.             that Ash's temporary files won't normally be seen.
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.           ASH Amiga Shell              Page 22                User's Guide
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.           Control Structures: if-then-elif-else-fi
  1460.  
  1461.             Ash  provides  a  set  of  control  structures  for   directing
  1462.             execution.  The most common of these is the  if-then-elif-else-
  1463.             fi statement.  It has several forms, but the  most  common  are
  1464.             these:
  1465.  
  1466.                if [ test expression ]
  1467.                then
  1468.                   statement
  1469.                   list
  1470.                fi
  1471.  
  1472.             The  test  expression is evaluated (more  on  test  expressions
  1473.             later), and if it is true,  the  statement  list  is  executed.
  1474.             The if statement can have an else part:
  1475.  
  1476.                if [ expression ]
  1477.                then
  1478.                   statement list
  1479.                else
  1480.                   statement list
  1481.                fi
  1482.  
  1483.             It can also have any number of else-if expressions:
  1484.  
  1485.                if [ expression ]
  1486.                then
  1487.                   stmt_list
  1488.                elif [ expression ]
  1489.                   stmt_list
  1490.                else
  1491.                   stmt_list
  1492.                fi
  1493.  
  1494.             Any valid Ash statement list can be used inside the if:
  1495.  
  1496.                if [ $a -lt 10 ]
  1497.                then
  1498.                   a = 20
  1499.                   echo "a WAS less than ten, but now it's $a"
  1500.                fi
  1501.  
  1502.             An alternative form of the if statement can  be  used  to  test
  1503.             the return code from a command.  For example,
  1504.  
  1505.                if cmp file1 file2
  1506.                then
  1507.                   echo 'Files are the same'
  1508.                fi
  1509.  
  1510.             If the command following the if  keyword  returns  TRUE  (or  a
  1511.             zero  return  code),  the  if  statement  proceeds  as  if   an
  1512.             expression returned true.
  1513.  
  1514.  
  1515.           ASH Amiga Shell              Page 23                User's Guide
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.           Control Structures: while-do-done
  1526.  
  1527.             A while loop is simply a method for executing a statement  list
  1528.             as long as a certain given condition is true.  For example,
  1529.  
  1530.                while [ ! -d ram:my_dir ]
  1531.                do
  1532.                    sleep 10
  1533.                done
  1534.  
  1535.             which is an endless loop which waits until  a  given  directory
  1536.             exists (because another process created  it).   It  checks  for
  1537.             the existence of ram:my_dir  every  10  seconds.   (Again  test
  1538.             expressions will be explained in detail later).   As  with  if-
  1539.             then-else statements, a while statement can examine the  return
  1540.             code from a command.  A particularly useful while loop of  that
  1541.             form is the following:
  1542.  
  1543.                while read in_line
  1544.                do
  1545.                     echo "We read: $in_line"
  1546.                done < input_file
  1547.  
  1548.             That while loop executes as long as the  read  command  returns
  1549.             TRUE.  The read command returns FALSE upon reaching the end  of
  1550.             the input file, so the loop terminates then.  The entire  while
  1551.             loop has its input redirected from a given file.  In  practice,
  1552.             of course, the echo statement would be  replaced  by  the  code
  1553.             which accomplishes what you desire.  Here is  another  example,
  1554.             like  the  above,  but  which  is  combined  with  Ash  command
  1555.             substitution:
  1556.  
  1557.                my_var = $(  while read in_line
  1558.                             do
  1559.                                echo "We Read: $in_line"
  1560.                             done < input_file
  1561.                          );
  1562.  
  1563.             That is identical to the above loop, but saves the output in  a
  1564.             variable called my_var.   You  could  then  echo  "$my_var"  to
  1565.             retrieve this output.
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.           ASH Amiga Shell              Page 24                User's Guide
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.           Control Structures: for-do-done
  1592.  
  1593.             Ash provides a for-do loop, but it differs from the  for  loops
  1594.             provided with more most programming  languages.   In  Ash,  for
  1595.             loops are used to execute  a  series  of  statements  for  each
  1596.             parameters in a list.  For example,
  1597.  
  1598.                for my_param in abc def ghi
  1599.                do
  1600.                     echo "my_param = $my_param"
  1601.                done
  1602.  
  1603.             The statement list inside the for loop  is  executed  once  for
  1604.             each parameter, and each time, the variable 'my_var' is set  to
  1605.             the parameter in question.  That is,  the  first  time  through
  1606.             the loop, my_var  is  abc, the second time, def, and the third,
  1607.             ghi.   For  loops  are  useful  when  combined  with   wildcard
  1608.             patterns:
  1609.  
  1610.                for file in *.c
  1611.                do
  1612.                     cp $file dh0:backups/$file.bak
  1613.                done
  1614.  
  1615.             That loop executes once for each c code  file  in  the  current
  1616.             directory, copying the file to the  directory  dh0:backups  and
  1617.             adding a '.bak' extension  in  the  process.   After  you  gain
  1618.             experience with Ash, you will become  proficient  at  executing
  1619.             similar simple programs from the  command  line.   Even  though
  1620.             this loop is only four lines, it is quite useful.  In fact,  it
  1621.             could be shortened to one line  by  separating  the  components
  1622.             with ';'.  This loop has been extended to also copy .h files:
  1623.  
  1624.              for file in *.c *.h; do cp $file dh0:backups/$file.bak; done
  1625.  
  1626.             For loops  can  only  index parameters.  They cannot be used to
  1627.             count.  For that, you must use a while  loop  with  the  inc or 
  1628.             expr function.
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.           ASH Amiga Shell              Page 25                User's Guide
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.           Test Expressions
  1658.  
  1659.             Test expression are used in if statements and while  statements
  1660.             to  test  a  given  expression  and  return   TRUE   or   FALSE
  1661.             appropriately.   Test  expressions  are  enclosed   in   square
  1662.             brackets   ('[   ]').   The  following   simple  operators  are
  1663.             available:
  1664.  
  1665.                -f fspec       TRUE if fspec exists and is a file
  1666.                -d fspec       TRUE if fspec exists and is a directory
  1667.                -s fspec       TRUE if fspec is a file and has a size of 0
  1668.                -r fspec       TRUE if fspec exists and is readable
  1669.                -w fspec       TRUE if fspec exists and is writable
  1670.                -x fspec       TRUE if fspec exists and is executable
  1671.                -z string      TRUE if string has a length of 0
  1672.                -n string      TRUE if string has a non-zero length
  1673.  
  1674.             The following comparison operators are available:
  1675.  
  1676.                n1 -eq n2      TRUE if n1 is numerically equal to n2
  1677.                n1 -ne n2      TRUE if n1 is numerically unequal to n2
  1678.                n1 -lt n2      TRUE if n1 is numerically less than n2
  1679.                n1 -gt n2      TRUE if n1 is numerically greater than n2
  1680.                n1 -le n2      TRUE if n1 is less than or equal to n2
  1681.                n1 -gt n2      TRUE if n1 is greater than or equal to n2
  1682.                s1 = s2        TRUE if s1 is the same string as s2
  1683.                s1 != s2       TRUE if s1 is not the same string as s2
  1684.  
  1685.             Also, boolean operators are available:
  1686.  
  1687.                ! e1           TRUE if sub-expression e1 is false
  1688.                e1 -a e2       TRUE if e1 and e2 are both TRUE
  1689.                e1 -o e2       TRUE if e1 or e2 is TRUE
  1690.  
  1691.             Thus, the following expressions are all TRUE:
  1692.  
  1693.                [ 1 -lt 3 ]
  1694.                [ 3 -lt 2 -o 1 -lt 0 -o 3 -eq 3 ]
  1695.                [ -z '' ]
  1696.                [ -n "hi" ]
  1697.                [ ! -z "hi" ]
  1698.                [ a = 'a' ]
  1699.                [ 'xyz' != 'abc' ]
  1700.                [ -d 'c:' ]
  1701.                [ -f 'c:dir' -a -f 's:startup-sequence' ]
  1702.  
  1703.             The boolean  and  operator  has  a  high  precedence  than  the
  1704.             boolean -o operator.  Note also that test  expressions  do  not
  1705.             print their result; they simple set the return code, which  can
  1706.             then be tested for.  A return code of zero  means  TRUE.   Here
  1707.             is an example usage of a test expression:
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.           ASH Amiga Shell              Page 26                User's Guide
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.                i = 1
  1725.                while [ $i -le 10 ]
  1726.                do
  1727.                   echo "index variable = $i"
  1728.                   inc i
  1729.                done
  1730.  
  1731.             Here is another example:
  1732.  
  1733.                function my_func {
  1734.                   if [ $# -ne 3 ]
  1735.                   then
  1736.                      echo "This function requires exactly 3 parameters"
  1737.                      return
  1738.                   fi
  1739.                }
  1740.  
  1741.             The  inc command is simply  a  way  to  increment  a  variable.
  1742.             There are other ways do it, but inc is the fastest.
  1743.  
  1744.             Test expressions are related to, but  should  not  be  confused
  1745.             with, the expr command.
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.           ASH Amiga Shell              Page 27                User's Guide
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.           Sub-Shell Execution
  1790.  
  1791.             Ash provides two mechanisms for  grouping  commands;  they  are
  1792.             closely related both in behaviour and syntax, but differ in  an
  1793.             important way.
  1794.  
  1795.             If a series of  statements  is  grouped  within  either  curly-
  1796.             braces  '{ }' or parentheses '( )', that statement list is said
  1797.             to be executed within a sub shell.  For example:
  1798.  
  1799.                { echo foo; echo bar }
  1800.             and
  1801.                ( read foo; read bar )
  1802.  
  1803.             are both sub-shell statements.  Subshells group their  enclosed
  1804.             commands, so that all the commands within the subshell share  a
  1805.             common environment.  One use  for  this  is  to  give  all  the
  1806.             commands a common input or output.  For example:
  1807.  
  1808.                { c:status
  1809.                  echo "Done with status command"
  1810.                  c:dir
  1811.                  echo "Done with dir command"
  1812.                } > out_file
  1813.  
  1814.             The output of all the commands within the subshell  goes  to  a
  1815.             common file.  This works for input, as well:
  1816.  
  1817.                { read foo; read bar } < in_file
  1818.  
  1819.             If you tried  to  redirect  the  input  of  each  read  command
  1820.             separately,  both  'foo'  and  'bar'  would  contain  the  same
  1821.             information.  By using a sub-shell, the  reads  are  sequential
  1822.             from the input file.
  1823.  
  1824.             The parenthetical subshell syntax differs from the  above  form
  1825.             only in that any variables declared  within  the  subshell  are
  1826.             local.  For example,
  1827.  
  1828.                [dh0:] answer = 42; echo $answer
  1829.                     42
  1830.                [dh0:]: ( answer = 7; echo $answer )
  1831.                     7
  1832.                [dh0:]: echo $answer
  1833.                     42
  1834.  
  1835.             Notice that the answer variable is 42  both  before  and  after
  1836.             the subshell, but  is  7  within  it.   Because  this  type  of
  1837.             subshell allocates space for local variables,  the  first  form
  1838.             is both faster and uses  less  memory.   It  is  the  preferred
  1839.             form, unless you do in fact need local  variables.   (Functions
  1840.             and aliases declared  within  the  parenthetical  subshell  are
  1841.             local as well).
  1842.  
  1843.  
  1844.  
  1845.           ASH Amiga Shell              Page 28                User's Guide
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.           File Name Mapping
  1856.  
  1857.             When Ash sees an unquoted file name,  it  maps  the  file  name
  1858.             from a Unix style file name to an  AmigaDos  style  file  name.
  1859.             The Unix style has several advantages.  First and  foremost,  a
  1860.             single  dot ('.') can be used to specify  the  current  working
  1861.             directory. For example,
  1862.  
  1863.                [dh0:]: assign this_dir: .
  1864.                [dh0:]: HOME=.
  1865.  
  1866.             assigns  'this_dir'  (a  device)   to   the   current   working
  1867.             directory, and then sets the Ash home directory to the  current
  1868.             directory.  The dot can be used in any command,  such  as  'cp'
  1869.             or 'mv', but it  cannot  be  quoted  or  it  looses  its  magic
  1870.             properties and becomes just a dot.  For example,
  1871.  
  1872.                [dh0:]: echo .
  1873.                     dh0:appl/excellence!/documents/ASH
  1874.                [dh0:]: echo "."
  1875.                     .
  1876.  
  1877.             In  addition,  a  path  beginning  with  a  slash ('/') will be
  1878.             mapped by Ash to be an AmigaDos absolute path name  instead  of
  1879.             a relative path name.  For example,
  1880.  
  1881.                run lse /usr/src/Ash/Parser.y
  1882.  
  1883.             really  edits  the  file  'dh0:usr/src/Ash/Parser.y'   if   the
  1884.             current device is dh0:.  Also, Ash  maps  two  sequential  dots
  1885.             ('..') to be the parent  directory  of  the  current  directory
  1886.             (which in AmigaDos is specified with a slash):
  1887.  
  1888.                run emacs ../../my_file.c
  1889.  
  1890.             The file my_file.c  in  the  directory  two  levels  above  the
  1891.             current directory is loaded into emacs.
  1892.  
  1893.             A tilde ('~') can be used to specify the contents of  the  HOME
  1894.             variable.  For example, if HOME is 'sys:usr/src/Ash',
  1895.  
  1896.                [dh0:]: echo ~/Parser.y
  1897.                     sys:usr/src/Ash/Parser.y
  1898.  
  1899.             Ash can be instructed not to perform this  file  name  mapping.
  1900.             See the options command for details.
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.           ASH Amiga Shell              Page 29                User's Guide
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.           Ash Scripts
  1922.  
  1923.             If a file containing Ash commands is in the  Ash  search  path,
  1924.             and has its script bit set, Ash will execute the file  directly
  1925.             as if it was a  binary  file;  there  is  no  need  to  use  an
  1926.             "execute" or other special  command.   Normally,  Ash  executes
  1927.             the file in its own  sub-shell.   Thus,  variables,  functions,
  1928.             and aliases defined within the script file are local.  Ash  can
  1929.             also "source" files (execute them but not in a subshell).
  1930.  
  1931.             Ash will happily co-exist with scripts from other  shells.   If
  1932.             Ash detects a file with the script bit set, it  first  examines
  1933.             the first two characters of the file.   If  they  are  '#!'  or
  1934.             ';!' Ash reads the rest of the first line, appends the name  of
  1935.             the script file, and  passes  the  string  to  AmigaDos  to  be
  1936.             executed.  For example, on my system I have scripts  from  Ash,
  1937.             Matt Dillon's shell, and the AmigaDos  "execute"  command.   My
  1938.             scripts either begin with:
  1939.  
  1940.                #!sys:bin/shell
  1941.  
  1942.             if the script is to be executed by Matt's shell, or
  1943.  
  1944.                ;!c:execute
  1945.  
  1946.             if the file is an "execute" script.  Since the first  character
  1947.             is recognized by  the  appropriate  shell  as  a  comment,  the
  1948.             script runs fine, and  Ash  knows  to  pass  execution  to  the
  1949.             correct shell.  It is  important  that  there  are  no  leading
  1950.             blanks or newlines before the '#!' or ';!'; they  must  be  the
  1951.             first two characters of the file.  This mechanism can  be  used
  1952.             with any other Amiga shell that recognizes  '#'  or  ';'  as  a
  1953.             comment character.
  1954.  
  1955.             If the script bit is not set, Ash will ignore the  file  unless
  1956.             you explicitly use the 'source' command.  Also,  if  the  shell
  1957.             does not automatically exit after  executing  the  script,  you
  1958.             must include an explicit exit  statement  at  the  end  of  the
  1959.             script (such as with Matt Dillon's Shell).
  1960.  
  1961.             (Note: there seems to be a bug someplace with  using  ;!execute
  1962.             for AmigaDos execute scripts.  It seems that execute  sometimes
  1963.             returns before the script  has  finished  running,  and  things
  1964.             tend to get a bit confused.  I do not  think  this  is  an  Ash
  1965.             problem, since I run the execute command the same way as I  run
  1966.             anything else).
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.           ASH Amiga Shell              Page 30                User's Guide
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.           Command Line Editing and History
  1988.  
  1989.             Ash provides mechanisms  for  recalling  and  editing  previous
  1990.             commands.  To obtain a  list  of  previous  commands,  use  the
  1991.             history  command.   By  default,  Ash  keeps  the  previous  32
  1992.             commands, although this number can be changed by  setting  the  
  1993.             HISTSIZE variable.
  1994.  
  1995.             In addition, command line editing  is  available  (but  can  be
  1996.             turned  off  -  see  the  options command).  The following keys
  1997.             have special meaning  (the  caret  mark  means  hold  down  the
  1998.             control key and press the following character):
  1999.  
  2000.                ^p or up arrow           - recall previous command
  2001.                ^n or down arrow         - recall next command
  2002.                ^b or left arrow         - move cursor left
  2003.                ^f or right arrow        - move cursor right
  2004.                ^m or return             - accept and execute current line
  2005.                ^a                       - move to beginning of line
  2006.                ^e                       - move to end of line
  2007.                ^k                       - kill to end of line
  2008.                ^l                       - redraw the current line
  2009.                ^d or delete key         - delete current character
  2010.                ^h or backspace          - delete previous character
  2011.                esc-f                    - move forward one word
  2012.                esc-b                    - move backward one word
  2013.                esc-d                    - delete the next word
  2014.                esc-<                    - move to first line in history
  2015.                esc->                    - move to last line in history
  2016.                esc-esc or tab           - filename completion
  2017.                ^r                       - reverse search for line
  2018.                ^o                       - execute line, move to next
  2019.                ^u                       - multiply next command by 4
  2020.                function keys            - insert defined text
  2021.  
  2022.             The basic  editing  commands  are  self  explanatory,  but  the
  2023.             others  may  not  be.   The   reverse search command is used to
  2024.             search for a string in the history list, and then  display  the
  2025.             line containing that string for further editing.  For  example,
  2026.             suppose your history list contained 4 lines, as follows:
  2027.  
  2028.                [dh0]: history
  2029.                     1: echo 'This is a test'
  2030.                     2: version
  2031.                     3: date
  2032.                     4: history
  2033.  
  2034.             Then, at the Ash prompt, type a  substring  from  any  previous
  2035.             command:
  2036.  
  2037.                [dh0:]: test
  2038.  
  2039.             When  you  press  ^r,  the  most  recent  line  containing  the
  2040.             substring will be displayed and available for editing:
  2041.  
  2042.  
  2043.           ASH Amiga Shell              Page 31                User's Guide
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.                [dh0:]: echo 'This is a test'
  2055.  
  2056.             This line can be edited, or accepted as is by pressing  return.
  2057.             If it is not the correct  line,  pressing  ^r  yet  again  will
  2058.             start  the  reverse  search  again  beginning  with  the   line
  2059.             previous to the one displayed.   Thus,  multiple  ^r's  can  be
  2060.             used to access the desired line.
  2061.  
  2062.             If the line is changed in any way, it  will  be  re-entered  at
  2063.             bottom of the history list as a new  command.   If  it  is  not
  2064.             edited, it will simply be  executed,  but  not  inserted  again
  2065.             into the history list (although this behaviour can  be  changed
  2066.             with the options command.
  2067.  
  2068.             The ^o key  is  useful  for  executing  a  series  of  commands
  2069.             multiple times.  Suppose your history list looks like this:
  2070.  
  2071.                1: echo $HISTSIZE
  2072.                2: date
  2073.                3: echo 'command 1'
  2074.                4: echo 'command 2'
  2075.                5: echo 'command 3'
  2076.  
  2077.             Use the ^p key or up  arrow  to  move  to  the  3rd  line.   By
  2078.             pressing the ^o key, that line is executed, and  Ash  remembers
  2079.             which line that was.  By pressing ^o again, the  next  line  is
  2080.             executed.  Upon reaching the end of the list, Ash moves to  the
  2081.             first line upon which ^o was used.  In  this  manner,  'command
  2082.             1', 'command 2', and 'command 3' would  be  echoed  repeatedly.
  2083.             Using any other movement or editing command will cause  Ash  to
  2084.             forget which line was the first, and you will have to  move  to
  2085.             it again.
  2086.  
  2087.             The ^u key causes the next command to be repeated  four  times.
  2088.             For example, pressing ^u followed by the '-' key  inserts  four
  2089.             dashes.  Pressing ^u followed by the delete  key  deletes  four
  2090.             characters.  The action of ^u is recursive;  two ^u's in a  row
  2091.             will repeat the next command 16 times.  Three would  repeat  64
  2092.             times.   Therefore,  to  insert  a  row  of  64   dashes,   use
  2093.             '^u^u^u-'.
  2094.  
  2095.             If you press a function key, Ash will examine the  contents  of
  2096.             the variable with the same  name.   For  example,  pressing  f1
  2097.             would cause Ash to look for  a  variable  named  'f1',  and  if
  2098.             found, insert the text it contains as if you had typed it.   If
  2099.             the text ends in  a  newline,  Ash  will  execute  the  command
  2100.             immediately; otherwise, it will simply display it  for  editing
  2101.             or execution.  For example:
  2102.  
  2103.                [dh0:]: f1="echo testing"
  2104.  
  2105.             would would just display "echo testing"  when  f1  is  pressed,
  2106.             but:
  2107.  
  2108.  
  2109.           ASH Amiga Shell              Page 32                User's Guide
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.                [dh0:]: f1="echo testing\n"
  2121.  
  2122.             would execute the command as well.
  2123.  
  2124.             In addition to the interactive  editing  facilities,  a  single
  2125.             command can be executed with the  'history  -e'  command.   You
  2126.             can specify either a substring of  the  command,  its  absolute
  2127.             number, or its relative number  by  using  a  negative  offset.
  2128.             For  example,  given  the  above  history  list,  all  of   the
  2129.             following would echo 'command 2':
  2130.  
  2131.                [dh0:]: history -e 'd 2'
  2132.                [dh0:]: history -e 4
  2133.                [dh0:]: history -e -2
  2134.  
  2135.             The executed command is not placed at the end  of  the  history
  2136.             list (see the  options command).  For convenience, 'history -e'
  2137.             has been aliased to  '!'.   Also,  'history  -e  -1'  has  been
  2138.             aliased to '!!' (similar to  csh, except that in Ash there must
  2139.             be a space between the '!' and the parameter).
  2140.  
  2141.             If you type a command line that would wrap onto the next  line,
  2142.             Ash will instead scroll the line 12 characters to the left  and
  2143.             let you continue typing.  If you move off either  side  of  the
  2144.             "sliding window", ash will adjust  the  line  accordingly.   If
  2145.             this behaviour does not appear to be  acting  correctly,  check
  2146.             the value of  the  COLUMNS and PNPC variables, described in the
  2147.             Reference Manual.  The COLUMNS variable should be  set  to  the
  2148.             number of columns in the current window,  and  PNPC  should  be
  2149.             set to the number of non-printable ANSI control  characters  in
  2150.             the Ash prompt (21 for  the  default  prompt).   If  either  of
  2151.             these numbers are wrong, long lines  will  display  improperly.
  2152.             Also, Ash line editing can be turned off  completely;  see  the
  2153.             options command for details.  In this case, no  line  scrolling
  2154.             is performed.  If the COLUMNS variable is set to less than  15,
  2155.             Ash will get confused.
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.           ASH Amiga Shell              Page 33                User's Guide
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.           Filename Completion
  2186.  
  2187.             Ash supports filename completion using  <esc><esc> or tab.  For
  2188.             example, suppose your current working  directory  contains  the
  2189.             following files:
  2190.  
  2191.                my_file.c
  2192.                another_c_file.c
  2193.                this_is_a_long_filename
  2194.                test_file2
  2195.                test_file3
  2196.  
  2197.             If Ash command line editing  is  turned  on  (see  the  options
  2198.             command), you can insert any file name into  the  command  line
  2199.             by typing part of the file name and  pressing  the  escape  key
  2200.             twice.  For example, suppose you typed:
  2201.  
  2202.                [dh0:]: cat ano
  2203.  
  2204.             and pressed <esc><esc>.  Ash would fill  in  the  rest  of  the
  2205.             file name for you:
  2206.  
  2207.                [dh0:]: cat another_c_file.c
  2208.  
  2209.             In fact, since 'a' is  enough  to  uniquely  specify  the  file
  2210.             name, you could have typed 'a<esc><esc>' for the  same  effect.
  2211.             In the case of  'test_file2'  and  'test_file3'  above,  typing
  2212.             'te' is not enough to uniquely specify the file, but  Ash  will
  2213.             help here too by filling in as much as it can:
  2214.  
  2215.                [dh0:]: echo te
  2216.  
  2217.             (press <esc><esc>)
  2218.  
  2219.                [dh0:]: echo test_file
  2220.  
  2221.             You would then have to type either '2' or  '3',  but  you  have
  2222.             still saved 7 characters of typing.
  2223.  
  2224.             Filename completion is useful not only to save typing,  but  to
  2225.             insure that you have not mis-typed the file name.  You can  use
  2226.             filename completion on paths, as well:
  2227.  
  2228.                [dh0:]: sys:S                      (press <esc><esc>)
  2229.                [dh0:]: sys:System/Fo              (type /Fo and <esc><esc)
  2230.                [dh0:]: sys:System/Format
  2231.  
  2232.             The tab key can also be used for  filename  completion  if  the
  2233.             proper option to Ash is set (see the options command).
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.           ASH Amiga Shell              Page 34                User's Guide
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.             Case is significant in  filename  completion.   Also,  if  file
  2252.             name mapping is enabled (see  the  options command), it will be
  2253.             performed on the  current  file  name,  if  applicable.   Thus,
  2254.             '/System/Fo' will be changed to  ':System/Format'  (notice  the
  2255.             first slash is changed to a colon).
  2256.  
  2257.             Ash is, I believe, the first  Amiga  shell  to  offer  filename
  2258.             completion.  You'll find it  addictive.   It  works  best  with
  2259.             hard or ram disks, since the directory seek speed is faster.
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.           ASH Amiga Shell              Page 35                User's Guide
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315.  
  2316.  
  2317.           Index to Users's Guide
  2318.  
  2319.             $#                          7, 18-19, 27
  2320.             $(                          3, 7, 14, 18, 21-22, 24
  2321.             $*                          18-19
  2322.             $0                          19
  2323.             $1                          18-19
  2324.             $2                          7, 19
  2325.             ( )                         3, 7, 14, 28
  2326.             -a                          10, 17-18, 20, 26
  2327.             -d fspec                    26
  2328.             -eq                         18, 26
  2329.             -f fspec                    26
  2330.             -gt                         6, 26
  2331.             -le                         26-27
  2332.             -lt                         6, 23, 26
  2333.             -n string                   26
  2334.             -ne                         26-27
  2335.             -o                          18, 26
  2336.             -r fspec                    26
  2337.             -s fspec                    26
  2338.             -w fspec                    26
  2339.             -x fspec                    26
  2340.             -z string                   26
  2341.             <esc><esc>                  3, 34
  2342.             alias                       2-3, 6-7, 17-20, 28, 30, 33
  2343.             append                      4, 11, 30
  2344.             assignment                  13, 22
  2345.             backspace                   31
  2346.             backticks                   21
  2347.             blanks                      15, 30
  2348.             boolean operators           26
  2349.             character class             16
  2350.             COLUMNS                     33
  2351.             Command Substitution        2-3, 7, 21-22, 24
  2352.             comment                     10, 30
  2353.             comparison operators        26
  2354.             Control Structures          2-3, 6-7, 23-25
  2355.             Copyright                   1-2, 4, 8-9, 17
  2356.             csh                         5, 33
  2357.             curly braces                18
  2358.             current working directory   10, 29, 34
  2359.             do                          2-6, 8-16, 18-20, 22, 24-31, 33
  2360.             done                        2, 6, 11-12, 18, 22, 24-25, 27-28
  2361.             dot                         29
  2362.             double quotes               13, 15
  2363.             down arrow                  31
  2364.             echo                        5-7, 11-12,  14-16,  18-20,  22-25,
  2365.                                         27-29, 31-34
  2366.             elif                        2, 18, 23
  2367.             else                        2, 9, 18, 23-24
  2368.             emacs                       3, 6, 10, 29
  2369.             enumerated characters       16
  2370.             esc-b                       31
  2371.  
  2372.  
  2373.           ASH Amiga Shell              Page 36                User's Guide
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.  
  2381.  
  2382.  
  2383.             esc-f                       31
  2384.             excellence!                 8, 29
  2385.             executable                  26
  2386.             Executing Commands          2, 10
  2387.             expr                        2, 7, 18, 21, 23-27
  2388.             extending Ash               18
  2389.             fi                          2-4, 6-7, 9, 11-32, 34-35
  2390.             File Name Mapping           2, 16, 29, 35
  2391.             Filename Completion         2-3, 31, 34-35
  2392.             for                         1-26, 28-35
  2393.             force                       20
  2394.             function                    2-3, 6-7, 17-22, 25, 27-28, 30-32
  2395.             function name               19
  2396.             functions                   2-3, 7, 17-19, 28, 30
  2397.             history                     2-3, 5, 7, 10, 31-33
  2398.             HISTSIZE                    31-32
  2399.             I/O Redirection             2-3, 11
  2400.             if                          2, 4, 6-7, 9-10, 12-16, 18-21,  23-
  2401.                                         30, 32-35
  2402.             IFS                         15
  2403.             inc                         4, 6-8, 12-14, 16-17, 22,  25,  27,
  2404.                                         30, 34-35
  2405.             index parameters            25
  2406.             input                       6, 11, 19, 24, 28
  2407.             internal field separator    15
  2408.             ksh                         1, 3, 5-6, 9, 13, 19
  2409.             Lattice                     8-9
  2410.             line editing                2-3, 31, 33-34
  2411.             list of aliases             17
  2412.             local                       3, 7, 18, 28, 30
  2413.             more input                  19
  2414.             newlines                    12, 15, 30
  2415.             number of parameters        15, 19
  2416.             parameter list              19
  2417.             Parameter Substitution      2, 15, 21
  2418.             parameters                  3, 6-7, 14-20, 25, 27
  2419.             path                        16, 18, 21-22, 29-30, 34
  2420.             Pipe Lines                  2, 12
  2421.             pipeline                    6
  2422.             PNPC                        33
  2423.             Priority                    2, 20
  2424.             range of characters         16
  2425.             read                        6, 9, 11-12, 21, 24, 26, 28, 30
  2426.             readable                    26
  2427.             return code                 23-24, 26
  2428.             reverse search              31-32
  2429.             right arrow                 31
  2430.             secondary Ash prompt string 19
  2431.             semicolon                   10
  2432.             set of characters           16, 21
  2433.             sh                          1-25, 27-35
  2434.             shift                       18-19
  2435.             simple command              6, 11-12
  2436.             simple operators            26
  2437.  
  2438.  
  2439.           ASH Amiga Shell              Page 37                User's Guide
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.             single parameter            15
  2450.             single quotes               13, 15
  2451.             slash                       13, 29, 35
  2452.             sleep                       10, 24
  2453.             slow script files           18
  2454.             string                      2, 10, 13-16, 19,  21,  26,  30-31,
  2455.                                         33
  2456.             sub shell                   28
  2457.             subshell                    6, 28, 30
  2458.             tabs                        15
  2459.             test expression             2, 23-24, 26-27
  2460.             then                        2, 6, 18, 23-24, 26-27, 29, 31, 34
  2461.             token                       21
  2462.             unalias                     17
  2463.             up arrow                    31-32
  2464.             variable                    2-3, 7, 13-15,  18-19,  21-22,  24-
  2465.                                         25, 27-33
  2466.             which                       3, 6-8, 13-16, 20-22, 24,  26,  29,
  2467.                                         32
  2468.             while                       2, 6, 11, 18, 24-27
  2469.             white space                 13, 15
  2470.             Wildcards                   2-3, 8, 16
  2471.             writable                    26
  2472.             [ ]                         16, 26
  2473.             ^a                          31
  2474.             ^b                          31
  2475.             ^d                          31
  2476.             ^e                          5, 31
  2477.             ^f                          31
  2478.             ^h                          31
  2479.             ^k                          31
  2480.             ^l                          5, 31
  2481.             ^m                          31
  2482.             ^n                          31
  2483.             ^o                          31-32
  2484.             ^p                          31-32
  2485.             ^r                          31-32
  2486.             { }                         28
  2487.  
  2488.  
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.           ASH Amiga Shell              Page 38                User's Guide
  2506.  
  2507.  
  2508.  
  2509.