home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 182.lha / CShell_v3.0a / shell.doc < prev    next >
Text File  |  1988-04-28  |  32KB  |  1,089 lines

  1.  
  2.         INSTRUCTIONS FOR SHELL Version: 3.00A 01-Sep-88
  3.         ===============================================
  4.  
  5.   Contents
  6.   --------
  7.  
  8.     I.    Description
  9.     II.   Overview of Major features
  10.     III.  Restrictions
  11.     IV.   PIPES
  12.     V.    Command Pre-processor
  13.     VI.   Command Line Editing
  14.     VII.  Function Keys
  15.     VIII. Shell Commands
  16.     IX.   Special Set Variables
  17.     X.    Advanced Topics
  18.     XI.   Example login file
  19.     XII.  Example script file
  20.  
  21.  
  22. I.  Description
  23.     -----------
  24.  
  25. Shell 3.00A is the follow of:
  26.     Shell V2.04 (C)Copyright 1986, Matthew Dillon, All Rights Reserved
  27.     Shell V2.04M-V2.07M by Steve Drew
  28.     Shell V2.08MI and V3.00A by Carlo Borreo & Cesare Dieni
  29.  
  30.  
  31.  
  32.     Carlo Borreo        Cesare Dieni
  33.     Via G. Berio 34        Via G. Taddei 3
  34.     I-18100 Imperia        I-56100 Pisa
  35.     Italy            Italy
  36.  
  37. For older version: Steve Drew at:
  38.  
  39.         ENET:    CGFSV1::DREW
  40.         ARPA:    drew%cfgsv1.dec.com@decwrl.dec.com
  41.         USENET:  {decvax|decwrl}!cgfsv1.dec.com!drew
  42.  
  43. or
  44.         52 Castledale Cres N.E.
  45.         Calgary, Alberta
  46.         Canada
  47.  
  48. You may distribute this program for non-profit only.
  49.  
  50.  
  51. II. OVERVIEW
  52.     --------
  53.  
  54. Shell provides a convient AmigaDos alternative command interface.
  55. All its commands are internal and thus does not rely on the c:
  56. commands for any functionality.
  57.  
  58. Major features include:
  59.  
  60.     -command line editing
  61.     -shell & Amigados search path support
  62.     -simple history
  63.     -redirection of any command
  64.     -piping
  65.     -aliases
  66.     -variables & variable handling (embedded variables)
  67.     -file name expansion via conventional wild carding ('?', '*' and more)
  68.     -conditionals (if/else ect..)
  69.     -source files  (w/ gotos and labels)
  70.     -many built in commands to speed things up
  71.  
  72.  
  73. III. RESTRICTIONS
  74.      ------------
  75.  
  76.     o AmigaDos execute command will not work. Alternative is to use shell
  77.       own script language (which is more powerful) or to do a 'run execute'.
  78.     o This version runs UNDER WORKBENCH 1.2 or 1.3.
  79.     o VDK handler has a bug with setting file dates so when using the copy
  80.       command and VDK you should use the -d switch otherwise your file date
  81.       in vdk: will be bad. (This is not a bug with shell)
  82.     o If using with conman it may be best to start shell with the -a switch
  83.       (shell -a .login) to turn off shell's command line editing and use
  84.       conmans instead.
  85.  
  86.  
  87. IV. NOTES ON PIPES
  88.     --------------
  89.  
  90.     PIPES have been implimented using temporary RAM: files.  Thus, you
  91.     should be careful when specifying a 'ram:*' expansion as it might
  92.     include the temp. files.  These files are deleted on completion of
  93.     the pipe segment.
  94.  
  95.     The file names used are completely unique, even with multiple shell
  96.     running simultaniously.
  97.  
  98.     My favorite new feature is the fact that you can now redirect to and
  99.     from, and pipe internal commands.  'echo charlie >ram:x', for
  100.     instance.  Another favorite:
  101.  
  102.        echo "echo mem | shell" | shell
  103.  
  104.     To accomplish these new features, I completely re-wrote the command
  105.     parser in execom.c
  106.  
  107.     NO BCPL program should be output-append redirected (>>).
  108.  
  109.  
  110. V.  COMMAND PRE-PROCESSOR
  111.     ---------------------
  112.  
  113.     Preprocessing is done on the command line before it is passed on to
  114.     an internal or external routine:
  115.  
  116.     ^c    where c is a character is converted to that control character.
  117.         Thus, say '^l' for control-l.
  118.  
  119.     $name    where name is a variable name.  Variable names can consist of
  120.         0-9, a-z, A-Z, and underscore (_).  The contents of the
  121.         specified variable is used.  If the variable doesn't exist,
  122.         the specifier is used.  That is, if the variable 'i' contains
  123.         'charlie', then '$i' -> 'charlie'.  If the variable 'i' doesn't
  124.         exist, then '$i'->'$i' .
  125.  
  126.     ;    delimits commands.   echo charlie ; echo ben.
  127.  
  128.     ' '    (a space). Spaces delimit arguments.
  129.  
  130.     "string" a quoted string.  For instance, if you want to echo five spaces
  131.         and an 'a':
  132.  
  133.         echo      a       -> a
  134.         echo "    a"      ->      a
  135.  
  136.     \c    overide the meaning of special characters.  '\^a' is a
  137.         circumflex and an a rather than control-a.  To get a backslash,
  138.         you must say '\\'.
  139.  
  140.         also used to overide alias searching for commands.
  141.  
  142.     >file    specify output redirection.  All output from the command is
  143.         placed in the specified file.
  144.  
  145.     >>file    specify append redirection (Does not work with BCPL programs).
  146.  
  147.     <file    specify input redirection.  The command takes input from the
  148.         file rather than the keyboard (note: not all commands require
  149.         input).  It makes no sense to say  'echo <charlie' since
  150.         the 'echo' command only outputs its arguments.
  151.  
  152.     |    PIPE specifier.  The output from the command on the left becomes
  153.         the input to the command on the right.  The current SHELL
  154.         implimentation uses temporary files to store the data.
  155.  
  156.     !!    execute the previously executed command.
  157.     !nn    (nn is a number).  Insert the history command numbered n (see
  158.         the HISTORY command)
  159.     !partial search backwards through the history list for a command which
  160.         looks the same as 'partial', and execute it.
  161.  
  162.     #    Enter comment.  The rest of the line is discarded (note: \#
  163.         will, of course, overide the comment character's special
  164.         meaning)
  165.  
  166.  
  167. VI. COMMAND LINE EDITING
  168.     --------------------
  169.  
  170.     o Command line can be upto 255 chars.
  171.     o Inserts and deletes are handled correctly over multiple screen lines.
  172.     o Shell will keep track of the line width should the window get resized.
  173.  
  174.     KEY DEFINITIONS:
  175.         Up Arrow    Recal previous commands
  176.         Down Arrow  Recal commands
  177.         Left Arrow  Move cursor about command line.
  178.         Right Arrow  "     "      "      "      "
  179.         Shift-Up Arrow    Get start of history
  180.         Shift-Down Arrow   "  end   "     "
  181.         Shift-Left Arrow  Moves cursor a bit left
  182.         Shift-Right Arrow   "     "    "  "  right
  183.         ^A        Toggle insert/overtype mode.
  184.         ^D        EOF
  185.         ^E        Put cursor at end of text.
  186.         ^K        Delete to end of line.
  187.         ^R        Retype current line.
  188.         ^U        Erase entire line.
  189.         ^X        Erase entire line.
  190.         ^Z        Put cursor at start of text.
  191.         f1 - f10    Execute command if variable exists.
  192.         F1 - F10    More commands (Shifted f keys).
  193.         Help        Invokes help command
  194.  
  195.  
  196. VII. FUNCTION KEYS
  197.      -------------
  198.  
  199.     Function keys now insert text to the current position on the command
  200.     line. They maybe terminated with a ^M (return). f1 would be non shifted
  201.     where as F1 is shifted.
  202.     Most of functions key have a default definition, but it may be changed.
  203.  
  204.       $ set f1 dir df0:^M
  205.  
  206.     will add the text 'dir df0:<return>' to the current line.
  207.  
  208.       $ set f1 dir
  209.  
  210.     would only add 'dir' you could then enter ' df0:<return>'
  211.  
  212.  
  213. VIII. SHELL COMMANDS
  214.       ---------------
  215.  
  216.    First to start shell from a CLI
  217.  
  218.    shell [-a] [-c command;command]
  219.  
  220.    where:
  221.     -a disables all command line editing features. This is useful for
  222.     when running shell over AUX:.
  223.  
  224.     -c allows execution of one command line and then exits out of shell.
  225.     This is useful for running a internal shell commands in the
  226.     background or from an external application. eg:
  227.  
  228.         Run shell -c dir df0:; copy -r df0: df1: >nil:; echo "Done"
  229.  
  230.     If you 'Run' shell in the background without the -c switch shell
  231.     will detect this and imediatley exit.
  232.  
  233.  
  234.    Command execution:
  235.  
  236.    Internal shell commands maybe abreviated.
  237.  
  238.    The first argument is the command-name... if it doesn't exist in the
  239.    list below and isn't an alias, it is assumed to be an external (disk)
  240.    command. At this point the shell pathing, and AmigaDos pathing is checked
  241.    in order to locate the command.
  242.  
  243.    AUTOMATIC SOURCING may be accomplished by naming shell scripts with a
  244.    .sh suffix.  Thus, if you say 'stuff' and the file 'stuff.sh' exists in
  245.    your current or C: directory, it will be SOURCED with any arguments you
  246.    have placed in the $_passed variable. This is equivalent to typing
  247.    'source stuff.sh'
  248.  
  249.  
  250.    Wild card expansions:
  251.     Most shell commands will accept multiple arguments that can
  252.     be as a result of wild card expansion. Also when the calling
  253.     an external command shell will first expand any wild cards
  254.     to seperate arguments. If you wish to have the external command
  255.     handle it's own wild carding you will need to insert quotes
  256.     around the special wild card characters ? and *.
  257.  
  258.     eg.
  259.         arc a new.arc *.txt    - shell will expand and pass to arc
  260.         arc a new.arc "*.txt"    - let arc expand the wild cards.
  261.  
  262.     Wild card expansions:
  263.  
  264.     ?    match any single character
  265.     *    match any string
  266.     .../*    recursive search down ALL sub directories from current level
  267.     !    Exclude pattern matching specifier
  268.     &    prefixed to patterns, ask confirmation for each file
  269.  
  270.     Examples:
  271.  
  272.     df0:.../*        all files in all directories on df0:
  273.     df0:.../!*.info     full directory tree of df0: but exclude
  274.                 any ugly .info files.
  275.     !*.o !*.c        will result in ALL files matching since what
  276.                 doesn't match the !*.o will match the !*.c
  277.     df1:&*            all files in root of df1:, but ask 
  278.                 confirmation for each
  279.  
  280.     LIST OF COMMANDS:
  281.     -----------------
  282.  
  283.     ABORTLINE
  284.     Usage    : abortline
  285.     Example : echo a;abort;echo b
  286.     Results    : a
  287.  
  288.     Causes the rest of the line to be aborted. Intended for use in
  289.     conjunction with exception handling.
  290.  
  291.     ADDBUFFERS
  292.     Usage    : addbuffers drive buffers
  293.     Example : addbuffers df0: 24
  294.  
  295.     Just like AmigaDOS addbuffer command, causes new buffers to be
  296.     allocated for disk I/O. Each buffer costs 512 bytes of CHIP memory.
  297.  
  298.     ALIAS
  299.     Usage    : alias [name [command string] ]
  300.     Example : alias vt "echo Starting VT100;run sys:tools/vt100"
  301.  
  302.     Sets a name to be a string. You can alias a single name to a set
  303.     of commands if you enclose them in quotes as above. By simply
  304.     typing vt, the command line above would be executed.
  305.  
  306.     Argument Passing to an Alias:
  307.  
  308.     Usage    : alias name "%var [command string]"
  309.     Example : alias xx "%q echo hi $q, how are ya."
  310.           xx Steve
  311.     Results : hi Steve, how are ya.
  312.  
  313.     The second form of the alias command allows passing of arguments
  314.     to any position within the command string via use of a variable
  315.     name. To pass arguments to the end of a command string this method
  316.     is actually not necessary.
  317.  
  318.     Typing "alias name" you will get the alias for that name, while with
  319.     "alias" you get a list of all alias.
  320.  
  321.     ASET
  322.     Usage    : aset name value
  323.     Example : aset INCLUDE include:
  324.  
  325.     Set a variable in a way that is compatible with Aztec SET command;
  326.     this is completely different from Shell variable.
  327.     May even be used to set ARP variables.
  328.  
  329.     ASSIGN
  330.     Usage    : assign [logical [physical] ]
  331.     Example : assign C: df1:c
  332.  
  333.     Use it like AmigaDOS assign command to set, remove or list
  334.     assignments of logical names to directories.
  335.  
  336.     CAT
  337.     Usage    : cat [-n][file file....]
  338.     Example : cat foo.txt
  339.  
  340.     Type the specified files onto the screen.  If no file is specified,
  341.     STDIN in used.  CAT is meant to output text files only.
  342.     Specifying -n option you will get numbered lines.
  343.  
  344.     CD
  345.     Usage    : cd [path]
  346.     Example : cd df0:devs/printers
  347.  
  348.     Change your current working directory.  You may specify '..' to go
  349.     back one directory (this is a CD specific feature, and does not
  350.     work with normal path specifications).
  351.  
  352.     CD without any arguments displays the path of the directory you
  353.     are currently in.
  354.  
  355.     CLOSE
  356.     Usage    : close filenumber
  357.  
  358.     Close the specified file opened by open.
  359.     See open and flist for more info.
  360.  
  361.     COPY
  362.     (CP)
  363.     Usage    : copy [-u][-d] file file
  364.     or    : copy [-u][-d] file1 file2...fileN dir
  365.     or    : copy [-r][-u][-d] dir1 dir2...dirN dir
  366.     options :
  367.         -r    recursive, copy all subdirectories as well.
  368.         -u    update, if newer version exist on dest, don't copy
  369.         -d    don't set destination file date to that of source.
  370.  
  371.     Example : copy -r df0: df1:
  372.  
  373.     Copy files or directories. When copying directories, the -r option
  374.     must be specified to copy subdirectories as well.  Otherwise, only
  375.     top level files in the source directory are copied.
  376.  
  377.     All files will be displayed as they are copied and directory's
  378.     displayed as they are created. This output can be suppessed by
  379.     redirecting to nil: eg. copy -r >nil: df0: df1:
  380.  
  381.     Copy will abort after current file on Control-C.
  382.  
  383.     Copy by default sets the date of the destination file to that of
  384.     the source file. To overide this feature use the -d switch.
  385.  
  386.     Another useful option is the -u (update) mode were copy will not
  387.     copy any files which exists already in the destination directory
  388.     if the destination file is newer or equal to the source file.
  389.     This is useful when developing code say in ram: eg. 'copy *.c ram:'
  390.     when done you can copy -u ram: df1: and only those modules you have
  391.     modified will be copied back.
  392.  
  393.     Copy command will now create the destination directory if it does
  394.     not exist when specified as 'copy [-r] dir dir'. If you specify
  395.     copy file file file dir, then 'dir' must already exist.
  396.  
  397.     CP
  398.     Equivalent to copy.
  399.  
  400.     DEC
  401.     Usage    : dec varname
  402.     Example : dec abc
  403.  
  404.     Decrement the numerical equivalent of the variable and place
  405.     the ASCII-string result back into that variable.
  406.  
  407.     DELETE
  408.     (RM)
  409.     Usage    : delete [-p][-r] file file file...
  410.     Example : delete foo.txt test.c
  411.  
  412.     Remove (delete) the specified files.  Remove always returns
  413.     errorcode 0.  You can remove empty directories.  The '-r' option
  414.     will remove non-empty directories by recursively removing all sub
  415.     directories.
  416.     You can remove delete-protected files specifying -p option.
  417.     If you specify any wildcard deletes the files will be listed as
  418.     they are deleted. This can be suppressed by redirecting to nil:
  419.  
  420.     DIR
  421.     (LS)
  422.     Usage    : dir [-sdf] [path path ... ]
  423.     Example : dir df0:
  424.     options :
  425.         -s  short multi(4) column display, directories in red pen.
  426.         -d  list directories only
  427.         -f  list files only
  428.  
  429.     Displays a directory of specified files. Default output shows
  430.     date, protection, block size, byte size and total space used.
  431.     Protections flags include new 1.2/1.3 flags (see under protect).
  432.     Files are alphabetically sorted, without case sensitivity.
  433.  
  434.     DISKCHANGE
  435.     Usage    : diskchange drive
  436.  
  437.     Like AmigaDOS diskchange.
  438.  
  439.     ECHO
  440.     Usage    : echo [-n] string
  441.     Example : echo hi there
  442.     Results : hi there
  443.  
  444.     Echo the string given. If -n switch given no newline is
  445.     appended.
  446.  
  447.     ELSE ;
  448.     Usage    : else ; command
  449.     Usage    : if -f foo.c ; else ; echo "Not there" ; endif
  450.  
  451.     Else clause, must follow an IF statement.
  452.  
  453.     ENDIF
  454.     Usage    : endif
  455.  
  456.     The end of an if statement.
  457.  
  458.     Note: if you return from a script file with unterminated IF's
  459.     and the last IF was false, prompt will be changed to an
  460.     underscore ('_') and no commands will be executed until
  461.     'endif' is typed.
  462.  
  463.     FAULT
  464.     Usage    : fault error1 .. errorN
  465.     Example : fault 205 212
  466.  
  467.     Like AmigaDOS fault, prints specified error messages.
  468.  
  469.     FILENOTE
  470.     Usage: filenote file1 .. filen  note
  471.  
  472.     Set AMIGADOS comment of the specified file. This is not very useful,
  473.     since in current implementation of Shell file comments are not listed
  474.     in directory, but it was so easy to implement...
  475.  
  476.     FLIST
  477.     Usage    : flist
  478.  
  479.     Lists the filenumbers of files opened by open.
  480.     See open and close for more info.
  481.  
  482.     FOREACH
  483.     Usage    : foreach varname ( strings ) command
  484.     Example : foreach i ( a b c d ) "echo -n $i;echo \" ha\""
  485.     Result    : a ha
  486.           b ha
  487.           c ha
  488.           d ha
  489.  
  490.     'strings' is broken up into arguments.  Each argument is placed in
  491.     the variable 'varname' in turn and 'command' executed.  To execute
  492.     multiple commands, place them in quotes.
  493.  
  494.     Foreach is especially useful when interpreting passed arguments in
  495.     an alias.
  496.  
  497.     eg.
  498.         foreach i ( *.pic ) viewilbm $i
  499.     assuming a.pic and b.pic in current directory the following commands
  500.     will occur:
  501.         viewilbm a.pic
  502.         viewilbm b.pic
  503.  
  504.     FOREVER
  505.     Usage    : forever command
  506.     or    : forever "command;command;command..."
  507.  
  508.     The specified commands are executed over and over again forever.
  509.  
  510.     -Execution stops if you hit ^C
  511.     -If the commands return with an error code.
  512.  
  513.    GOTO
  514.     Usage    : goto label
  515.     Example :
  516.           label start
  517.             echo "At start"
  518.             dir ram:
  519.             goto start
  520.  
  521.     Goto the specified label name.  You can only use this command from a
  522.     source file. Labels may now be forward or reverse from current
  523.     position.
  524.  
  525.     HELP
  526.     Usage    : help
  527.     Example : help
  528.  
  529.     Simply displays all the available commands.  The commands are
  530.     displayed in search-order.  That is, if you give a partial name
  531.     the first command that matches that name in this list is the one
  532.     executed.  Generally, you should specify enough of a command so that
  533.     it is completely unique.
  534.  
  535.     HISTORY
  536.     Usage    : history [partial_string]
  537.     Example : history
  538.  
  539.     Displays the enumerated history list.  The size of the list is
  540.     controlled by the _history variable.  If you specify a partial-
  541.     string, only those entries matching that string are displayed.
  542.  
  543.     HOWMANY
  544.     Usage    : howmany
  545.  
  546.     This command tells you how many instances of Shell are running
  547.     in your system.
  548.  
  549.     HTYPE
  550.     Usage    : htype file1 .. filen
  551.  
  552.     Displays the specified files in hex and ASCII, just like the system
  553.     command Type file opt h. Especially suitable for binary files.
  554.  
  555.     IF
  556.     Usage    : if [-n] argument conditional argument ;
  557.     or    : if [-n] argument
  558.     or    : if [-n] -f file
  559.     or    : if [-n] -d file/dir
  560.     or    : if [-n] -m
  561.     or    : if [-n] -t file file1 .. fileN
  562.  
  563.     If a single argument is something to another argument.  Conditional
  564.     clauses allowed:
  565.  
  566.     <, >, =, and combinations (wire or).  Thus <> is not-equal, >=
  567.     larger or equal, etc...
  568.  
  569.     If arguments are not numeric, they are compared as strings.
  570.  
  571.     Usually the argument is either a constant or a variable ($varname).
  572.  
  573.     The second form if IF is conditional on the existance of the argument.
  574.     If the argument is a "" string, then false , else TRUE.
  575.  
  576.     The third form of IF used by -f switch checks for existance of
  577.     the specified file.
  578.  
  579.     Switch -d tests the type of the object specified: if it is a
  580.     directory, then TRUE; if it is a file (or it doesn't exist)
  581.     then FALSE.
  582.  
  583.     Switch -m is used to test if FAST memory is present, i.e. wheter
  584.     more than 512K RAM are available.
  585.     Example (to be included in a login.sh file):
  586.     if -m; resident -a as ln cc; endif
  587.  
  588.     Using -t form compares the date and time of the first file with
  589.     all the others; if the first is younger than ALL the others, then
  590.     FALSE, else TRUE. If a file doesn't exists, it is considered as
  591.     being older.
  592.     This feature is especially useful for building makefiles without
  593.     using any MAKE utility.
  594.     Example:
  595.     if -t test.o test.asm test.i ; asm -o test.o test.asm ; endif
  596.  
  597.     Switch -n (NOT) reverses the result.
  598.  
  599.     When using 'IF' command interactively if you are entering commands
  600.     following an 'IF' that was false, the prompt will be set to a
  601.     underscore '_ ' to indicate all commands will be ignored until
  602.     an 'ELSE' or 'ENDIF' command is seen.
  603.  
  604.     INC
  605.     Usage    : inc varname
  606.     Example : inc abc
  607.  
  608.     Increment the numerical equivalent of the variable and place
  609.     the ascii-string result back into that variable.
  610.  
  611.     INFO
  612.     Usage    : info
  613.  
  614.     Display Device statistics for all the disk-type devices in system
  615.     (DFk:, HDk, JHk:, RAM:, RDk: ...), just like the system command
  616.     info. Gives block used/free, % used, errs, status and volume name.
  617.  
  618.     INPUT
  619.     Usage    : input var var ... var
  620.     Example : input abc
  621.  
  622.     Input from STDIN (or a redirection, or a pipe) to a variable.  The
  623.     next input line is placed in the variable.
  624.  
  625.     JOIN
  626.     Usage    : join [-r] file1..fileN destfile
  627.     Example : join part1 part2 part3 total
  628.  
  629.     Joins the specified files to get destfile. If destfile already
  630.     exists, an error message is generated and operation is aborted,
  631.     unless you specify -r (replace) option.
  632.  
  633.     LABEL
  634.     Usage    : label name
  635.  
  636.     Create a program label right here. Used in source files, can then
  637.     GOTO a label.
  638.  
  639.     LS
  640.     Equivalent to dir.
  641.  
  642.     MD
  643.     Equivalent to mkdir.
  644.  
  645.     MEM
  646.     Usage    : mem
  647.  
  648.     Display current memory statistics for CHIP memory and
  649.     FAST memory (if any installed).
  650.  
  651.     MKDIR
  652.     (MD)
  653.     Usage    : mkdir name name name...
  654.     Example : mkdir df0:stuff
  655.  
  656.     Create the specified directories.
  657.  
  658.     MV
  659.     Equivalent to rename.
  660.  
  661.     OPEN
  662.     Usage    : open filename filemode filenumber
  663.     Example : open RAM:data w 1
  664.  
  665.     This allows you to open a file, redirect to it as many commands
  666.     as you like, then close it.
  667.     Filename is any valid AmigaDOS filename, filemode is either r
  668.     for read or w for write, filenumber is a number between 1 and 10.
  669.     To redirect a program to or from an open file, use as your redir
  670.     filename a dot followed by the filenumber.
  671.     Here is a complete example:
  672.  
  673.         open RAM:data w 1
  674.         echo -n 2+2= >.1
  675.         rpn 2 2 + . CR >.1
  676.         close 1
  677.         type RAM:data    # will display 2+2=4
  678.     See also close, flist.
  679.  
  680.     PATH
  681.     Usage    : path
  682.  
  683.     Used to list AmigaDOS path. In current version can't be used to
  684.     set it.
  685.  
  686.     PRI
  687.     Usage    : pri clinumber pri
  688.     Example : pri 1 20
  689.  
  690.     Change the priority of the specified task (use PS command to
  691.     determine clinumber).
  692.  
  693.     PROTECT
  694.     Usage    : protect file1 ... filen [flags]
  695.     Example : protect myfile rwe
  696.  
  697.     Set AMIGADOS file protection flags for the file specified. Valid
  698.     flags are h, s, p, a, r, w, e, d.
  699.     If you don't specify the flags, all flags are cleared.
  700.     Bit 'a' is new to WorkBench 1.2, while 'h', 's', 'p' are new to 1.3.
  701.  
  702.     PS
  703.     Usage    : ps
  704.  
  705.     Gives status of DOS processes.  eg:
  706.  
  707.     Proc Command Name    CLI Type    Pri.  Address  Directory
  708.      1   SHELL        Initial CLI   0      97b0  Stuff:shell
  709.      2   sys:c/clockmem    Background  -10    2101a8  Workdisk:
  710.      3   c:emacs        Background    0    212f58  Stuff:shell
  711.      4   sys:c/VT100    Background    0    227328  Workdisk:
  712.  
  713.     Address is the addres of the task, directory is the process
  714.     currently CD'd directory.
  715.  
  716.     PWD
  717.     Usage    : pwd
  718.  
  719.     Rebuild _cwd by backtracing from your current directory.
  720.  
  721.     QUIT
  722.     Usage    : quit
  723.  
  724.     Quit out of Shell back to CLI.
  725.  
  726.     RBACK
  727.     Usage    : rback command
  728.  
  729.     Start a new process executing the specified command, but can't do
  730.     input/output. Equivalent to 'run command >NIL: <NIL:'.
  731.     This command is not fully reliable: use at your own risk.
  732.  
  733.     RENAME
  734.     (MV)
  735.     Usage    : rename from to
  736.     or    : rename from from from ... from todir
  737.  
  738.     Allows you to rename a file or move it around within a disk.
  739.     Allows you to move 1 or more files into a single directory.
  740.  
  741.     RESIDENT
  742.     Usage    : resident [-a][-r] [files]
  743.  
  744.     This is ARP resident. Commands are searched by Shell in resident
  745.     list BEFORE of searching on any external device.
  746.     Option -a loads RESIDENT programs, -r removes them.
  747.     Resident with no args lists resident programs.
  748.     Not all programs can run as resident, see ARP docs for more info.
  749.  
  750.     RETURN
  751.     Usage    : return [n]
  752.     Example : return 10
  753.  
  754.     Exit from a script file, or quit from shell with optional
  755.     exit code.
  756.  
  757.     RM
  758.     Equivalent to delete.
  759.  
  760.     RPN
  761.     Usage    : rpn expression
  762.     Example : rpn 3 7 * . CR    # Prints the value 21
  763.  
  764.     Evaluate an RPN expression. May be useful for simple calculations,
  765.     but needs some work to be really useful.
  766.     Use "rpn help" to get a list of commands, with the number of
  767.     arguments and of results.
  768.     Here are some commands:
  769.  
  770.     .    Prints value on stack
  771.     CR    Prints a CR
  772.     STR    Use "STR string" to get a pointer to string on stack
  773.     LEN, STRCMP, STRVAR String operations
  774.  
  775.     RUN
  776.     Usage    : run prgm args
  777.     Example : run emacs test.c
  778.  
  779.     Start a new process executing the specified command.
  780.     In current implementation run command can't be redirected.
  781.     This command is not fully reliable: use at your own risk.
  782.     See also rback.
  783.  
  784.     SEARCH
  785.     Usage    : search [-w][-c][-n][-r][-e][-q] filelist string
  786.  
  787.     Search specified files for a string. Only lines containing the
  788.     specified strings are displayed.
  789.  
  790.     If you specify any directory in filelist, and use the -r (recurse)
  791.     switch, all files in directory are recursively searched.
  792.  
  793.     Lines are numbered for default; use -n (number) switch to turn off
  794.     line numbering.
  795.  
  796.     Search is normally not case sensitive; use -c (case) flag to turn ON
  797.     case sensitivity.
  798.  
  799.     By specifying -e (exclude) switch, only lines NOT containing the
  800.     specified string are listed.
  801.  
  802.     Using -w (wild) flag, only the lines matching with the string are
  803.     listed.
  804.     Notes to wild card matching;
  805.     - Uses Shell standard matching.
  806.     - Wild cards allowed are *, ?, !.
  807.     - Matching is not case sensitive (even if you use -c flag).
  808.     - The WHOLE line must match the string, not only a substring.
  809.     - String MUST be enclosed in quotes to avoid wildcard expansion
  810.  
  811.     Flag -q (quiet) suppresses printing of file names.
  812.  
  813.     Examples:
  814.         search -c -r df0:include ACCESS
  815.     Find all occurrencies of ACCESS (in uppercase) in all files
  816.     contained in include directory.
  817.         search -w shell.h "#define*"
  818.     Lists only lines of file beginning with (not simply containing)
  819.     #define.
  820.  
  821.     SET
  822.     Usage    : set [name] [string]
  823.     Example : set abc hello
  824.  
  825.     Set with no args lists all current variable settings.
  826.     Set with one arg lists the setting for that particular variable.
  827.     Specifying name and string, stores the string into variable name.
  828.  
  829.     Also See the section on special _variables.
  830.  
  831.  
  832.     SLEEP
  833.     Usage    : sleep timeout
  834.     Example : sleep 10
  835.  
  836.     Sleep for 'timeout' seconds, or until ^C typed.
  837.  
  838.     STACK
  839.     Usage    : stack [number]
  840.     Example : stack 8000
  841.  
  842.     Changes the default stack for this CLI. Without arguments, prints
  843.     it.
  844.  
  845.     STRHEAD
  846.     Usage    : strhead varname breakchar string
  847.     Example : strhead j . foobar.bas
  848.           echo $j
  849.     Result    : foobar
  850.  
  851.     Remove everything after and including the breakchar in 'string' and
  852.     place in variable 'varname'.
  853.  
  854.     STRINGS
  855.     Usage    : strings file1..fileN minlenght
  856.     Example : strings c:dir c:list shell 7
  857.  
  858.     Prints strings contained in specified files (usually binary)
  859.     with lenght >= minlenght.
  860.  
  861.     STRTAIL
  862.     Usage    : strtail varname breakchar string
  863.     Example : strtail j . foobar.bas ; echo $j
  864.     Result    : bas
  865.  
  866.     Remove everything before and including the breakchar in 'string' and
  867.     place in variable 'varname'.
  868.  
  869.     SOURCE
  870.     Usage    : source file [arguments]
  871.     Example : source mymake.sh all
  872.     Result    : source file 'mymake.sh' called with var _passed = 'all'
  873.  
  874.     Execute commands from a file.  You can create SHELL programs in
  875.     a file and then execute them with this command.  Source'd files
  876.     have the added advantage that you can have loops in your command
  877.     files (see GOTO and LABEL).  You can pass SOURCE files arguments
  878.     by specifying arguments after the file name.  Arguments are passed
  879.     via the _passed variable (as a single string).
  880.  
  881.     Automatic 'sourcing' is accomplished by placing a .sh extension on
  882.     the file and executing it as you would a C program:
  883.  
  884.     --------- file hello.sh ---------
  885.     foreach i ( $_passed ) "echo yo $i"
  886.     ---------------------------------
  887.  
  888.     $ hello a b c
  889.     yo a
  890.     yo b
  891.     yo c
  892.  
  893.     TYPE
  894.     Equivalent to CAT.
  895.  
  896.     TOUCH
  897.     Usage    : touch file1 .. fileN
  898.  
  899.     Sets DateStamp on the specified files to the current date and time.
  900.  
  901.     UNALIAS
  902.     Usage    : unalias name .. name
  903.     Example : unalias vt
  904.  
  905.     Delete aliases..
  906.  
  907.     UNSET
  908.     Usage    : unset name .. name
  909.     Example : unset abc
  910.  
  911.     Unset one or more variables.  Deletes them entirely.
  912.  
  913.     VER
  914.     Usage    : ver
  915.  
  916.     Show current version name, & authors.
  917.  
  918.     WINDOW
  919.     Usage    : window [-q][-f][-b][-l][-s] [dimensions]
  920.     Options    :
  921.         -f    (front) Window to front
  922.         -b    (back)  Window to back
  923.         -l    (large) Window to maximum size
  924.         -s    (small) Window to minimum size
  925.         -a    (activate)
  926.         -q    (query) Lists screens and windows open
  927.  
  928.     Various operations on CLI window. If dimensions are specified,
  929.     they must be in the form x y width height, with values separated
  930.     by spaces.
  931.     Switching very fast back and forth from small to big window may
  932.     cause an apparent lock-up; in this case, just resize the window
  933.     with the mouse.
  934.  
  935.  
  936. IX. SPECIAL SET VARIABLES
  937.     ---------------------
  938.  
  939.     _prompt
  940.     This variable is set to the command you wish executed that will
  941.     create your prompt. This can contain escape sequences if you wish.
  942.     The if command will set the prompt to a '_ ' if commands are
  943.     disabled while waiting for a 'endif' or 'else' command. Interactive
  944.     mode only.
  945.  
  946.     _history
  947.     This variable is set to a numerical value, and specifies how far
  948.     back your history should extend.
  949.  
  950.     _debug
  951.     Debug mode... use it if you dare.  must be set to some value
  952.  
  953.     _verbose
  954.     Verbose mode (for source files).  display commands as they are
  955.     executed.
  956.  
  957.     _maxerr
  958.     The worst (highest) return value to date.  To use this, you usually
  959.     set it to '0', then do some set of commands, then check it.
  960.  
  961.     _lasterr
  962.     Return code of last command executed.  This includes internal
  963.     commands as well as external comands, so to use this variables
  964.     you must check it IMMEDIATELY after the command in question.
  965.  
  966.     _cwd
  967.     Holds a string representing the current directory we are in from
  968.     root.  The SHELL can get confused as to its current directory if
  969.     some external program changes the directory.  Use PWD to rebuild
  970.     the _cwd variable in these cases.
  971.  
  972.     _passed
  973.     This variable contains the passed arguments when you SOURCE a file
  974.     or execute a .sh file.  For instance:
  975.  
  976.     test a b c d
  977.  
  978.     -------- file test.sh ----------
  979.     echo $_passed
  980.     foreach i ( $_passed ) "echo YO $i"
  981.     --------------------------------
  982.  
  983.     _path
  984.     This variable contains the search path when the shell is looking
  985.     for external commands.  The format is:  DIR,DIR,DIR  Each DIR must
  986.     have a trailing ':' or '/'.  The current directory is always
  987.     searched first.  The entire path will be searched first for the
  988.     <command>, then for <command>.sh (automatic shell script sourcing).
  989.  
  990.     The default _path is set to  "c:,df1:c/,df0:c/,ram:,ram:c/"
  991.     When using 'run' command Shell will now use it's own search
  992.     path first to find the command to run. If it fails to find
  993.     the command (but the Run command was found) it executes the
  994.     command line anyway to let amigaDos search path take over.
  995.  
  996.     _insert
  997.     Sets the default for insert/overtype mode for command line
  998.     editing. ^A toggles between, but after <RET> the default is
  999.     set back as indicated by this variable. By default _insert is 1
  1000.     indicating insert mode on setting to zero will make overtype
  1001.     the default.
  1002.  
  1003.     _width
  1004.     Indicates the console window width, 77 if unset.
  1005.     Will change automatically if the user resizes the window.
  1006.  
  1007.     _titlebar
  1008.     Used to set window's title bar.
  1009.  
  1010. X.  ADVANCED TOPICS
  1011.     ---------------
  1012.  
  1013.     EXCEPTION_PROCESSING:
  1014.  
  1015.     if no _except variable exists, any command which fails causes the
  1016.     rest of the line to abort as if an ABORTLINE had been executed.  If
  1017.     the _except variable exists, it is of the form:
  1018.  
  1019.     "nnn;commands..."
  1020.  
  1021.     where nnn is some value representing the minimum return code required
  1022.     to cause an error.  Whenever a command returns a code which is
  1023.     larger or equal to nnn, the commands in _except are executed before
  1024.     anything.  WHEN _except EXISTS, THE COMMAND LINE DOES NOT ABORT
  1025.     AUTOMATICALLY.  Thus, if you want the current line being executed
  1026.     to be aborted, the last command in _except should be an "abortline".
  1027.  
  1028.     exception handling is disabled while in the exception handling routine
  1029.     (thus you can't get into any infinite loops this way).
  1030.  
  1031.     Thus if _except = ";", return codes are completely ignored.
  1032.  
  1033.     example:
  1034.  
  1035.     set _except "20;abortline"
  1036.  
  1037. XI. EXAMPLE LOGIN FILE
  1038.     ------------------
  1039.  
  1040. from a CLI or the startup-script say 'SHELL filename'.  That file
  1041. is sourced first.  thus, 'SHELL .login' will set up your favorite
  1042. aliases:
  1043.  
  1044.  
  1045. # -Steve's .login file- #
  1046.  
  1047. echo -n "Enter Date [DD-MMM-YY HH:MM] ";input new; DATE $new
  1048.  
  1049. # -------Function keys-------- #
  1050.  
  1051. set f1 "dir df0:"^M
  1052. set f2 "dir df1:"^M
  1053. set F1 "dir -s df0:"^M
  1054. set F2 "dir -s df1:"^M
  1055. set f3 info^M
  1056. set f4 ps^M
  1057.  
  1058. # ---------Quickies---------- #
  1059.  
  1060. alias print "%q copy $q prt:"
  1061. alias tosys "assign c: SYS:c"
  1062. alias toram "assign c: RAM:c;"
  1063. alias tomanx "assign c: MANX:c; manxinit"
  1064. alias wb "loadwb"
  1065. alias pref "sys:preferences"
  1066. alias cal "run sys:utilities/calculator"
  1067.  
  1068. # ------Applications---------- #
  1069.  
  1070. alias em "run emacs"
  1071. alias vt "run sys:c/VT100"
  1072.  
  1073. # --------Finish Up----------- #
  1074.  
  1075. ver ;echo -n "Shell loaded on ";date
  1076.  
  1077. XII. Example Source file
  1078.      -------------------
  1079.  
  1080. # ---- MANXINIT.SH ------ #
  1081.  
  1082. aset INCLUDE AC:include
  1083. aset CCTEMP=ram:
  1084. makedir ram:lib;aset CLIB RAM:lib/;copy AC:lib/$libfile ram:lib"
  1085. alias cleanup "rm >NIL: -r ram:lib"
  1086.  
  1087. #run make in background at lower priority:
  1088. alias make "%q run ChangeTaskPri -5 +^J^J MAKE $q"
  1089.