home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 074.lha / CShell / shell.doc < prev    next >
Text File  |  1986-11-20  |  26KB  |  917 lines

  1.  
  2.           INSTRUCTIONS FOR SHELL Version: 2.07M 10-Sep-87
  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 V2.07M is the follow on to 2.04,5,6M which originated from:
  26.     Shell V2.04 by Matt Dillon:
  27.     Shell V2.04 (C)Copyright 1986, Matthew Dillon, All Rights Reserved
  28.     Enhanced by permission by Steve Drew.
  29.  
  30.     You may distribute this program for non-profit only.
  31.  
  32.  
  33.  
  34. II. OVERVIEW
  35.     --------
  36.  
  37.     Shell provides a convient AmigaDos alternative command interface.
  38.     All it's commands are internal and thus does not rely on the c: 
  39.     commands for any functionality (except the run command).
  40.  
  41.     
  42.     Major features include:
  43.  
  44.     -command line editing
  45.     -shell & Amigados search path support
  46.     -simple history
  47.     -redirection of any command
  48.     -piping
  49.     -aliases
  50.     -variables & variable handling (embedded variables)
  51.     -file name expansion via conventional wild carding ('?' and '*')
  52.     -conditionals (if/else ect..)
  53.     -source files  (w/ gotos and labels)
  54.     -many built in commands to speed things up
  55.  
  56.  
  57. III. RESTRICTIONS
  58.      ------------
  59.  
  60.     o AmigaDos execute command will not work. Alternative is to use shell
  61.       own script language (which is more powerful) or to do a 'run execute'.
  62.     o This version runs UNDER WORKBENCH 1.2 ONLY.
  63.     o VDK handler has a bug with setting file dates so when using the copy
  64.       command and VDK you should use the -d switch otherwise you file date
  65.       in vdk: will be bad. (This is not a bug with shell)
  66.     o If using with conman it may be best to start shell with the -a switch
  67.       (shell -a .login) to turn off shell's command line editing and use 
  68.       conmans instead.    
  69.  
  70. IV. NOTES ON PIPES
  71.     --------------
  72.  
  73.     PIPES have been implimented using temporary RAM: files.  Thus, you
  74.     should be careful when specifying a 'ram:*' expansion as it might
  75.     include the temp. files.  These files are deleted on completion of
  76.     the pipe segment.
  77.  
  78.     The file names used are completely unique, even with multiple shell
  79.     running simultaniously.
  80.  
  81.     My favorite new feature is the fact that you can now redirect to and
  82.     from, and pipe internal commands.  'echo charlie >ram:x', for
  83.     instance.  Another favorite:
  84.  
  85.        echo "echo mem | shell" | shell
  86.  
  87.     To accomplish these new features, I completely re-wrote the command
  88.     parser in execom.c
  89.   
  90.     NO BCPL program should be output-append redirected (>>).
  91.  
  92.  
  93. V.  COMMAND PRE-PROCESSOR
  94.     ---------------------
  95.  
  96.     Preprocessing is done on the command line before it is passed on to
  97.     an internal or external routine:
  98.  
  99.     ^c       where c is a character is converted to that control character.
  100.              Thus, say '^l' for control-l.
  101.  
  102.     $name    where name is a variable name.  Variable names can consist of
  103.              0-9, a-z, A-Z, and underscore (_).  The contents of the
  104.              specified variable is used.  If the variable doesn't exist,
  105.              the specifier is used.  That is, if the variable 'i' contains
  106.              'charlie', then '$i' -> 'charlie'.  If the variable 'i' doesn't
  107.              exist, then '$i'->'$i' .
  108.  
  109.     ;        delimits commands.   echo charlie ; echo ben.
  110.  
  111.     ' '      (a space). Spaces delimit arguments.
  112.  
  113.     "string" a quoted string.  For instance, if you want to echo five spaces
  114.              and an 'a':
  115.  
  116.              echo      a       -> a
  117.              echo "    a"      ->      a
  118.  
  119.     \c       overide the meaning of special characters.  '\^a' is a
  120.              circumflex and an a rather than control-a.  To get a backslash,
  121.              you must say '\\'.
  122.  
  123.              also used to overide alias searching for commands.
  124.  
  125.     >file    specify output redirection.  All output from the command is
  126.              placed in the specified file.
  127.  
  128.     >>file   specify append redirection (Does not work with BCPL programs).
  129.  
  130.     <file    specify input redirection.  The command takes input from the
  131.              file rather than the keyboard (note: not all commands require
  132.              input).  It makes no sense to say  'echo <charlie' since
  133.              the 'echo' command only outputs its arguments.
  134.  
  135.     |        PIPE specifier.  The output from the command on the left becomes
  136.              the input to the command on the right.  The current SHELL
  137.              implimentation uses temporary files to store the data.
  138.  
  139.     !!       execute the previously executed command.
  140.     !nn      (nn is a number).  Insert the history command numbered n (see
  141.              the HISTORY command)
  142.     !partial search backwards through the history list for a command which
  143.              looks the same as 'partial', and execute it.
  144.  
  145.     #        Enter comment.  The rest of the line is discarded (note: \#
  146.              will, of course, overide the comment character's special
  147.              meaning)
  148.  
  149.  
  150. VI. COMMAND LINE EDITING
  151.     --------------------
  152.    
  153.     o Command line can be upto 255 chars.
  154.     o Inserts and deletes are handled correctly over multiple screen lines. 
  155.     o Shell will keep track of the line width should the window get resized.
  156.  
  157.      KEY DEFINITIONS:
  158.               Up Arrow    Recal previous commands
  159.            Down Arrow  Recal commands
  160.          Left Arrow  Move cursor about command line.
  161.          Right Arrow  "     "      "      "      "
  162.          ^A        Toggle insert/overtype mode.
  163.          ^D        EOF
  164.          ^E        Put cursor at end of text.
  165.          ^K        Delete to end of line.
  166.         ^R        Retype current line.
  167.         ^U        Erase entire line.
  168.         ^X        Erase entire line.
  169.         ^Z        Put cursor at start of text.
  170.         f1 - f10    Execute command if variable exists.
  171.         F1 - F10    More commands (Shifted f keys).
  172.         Help         invokes help command
  173.  
  174.  
  175. VII. FUNCTION KEYS
  176.      -------------
  177.         
  178.     Function keys now insert text to the current position on the command
  179.     line. They maybe terminated with a ^M (return). f1 would be non shifted
  180.     where as F1 is shifted.
  181.     
  182.       $ set f1 dir df0:^M
  183.  
  184.     will add the text 'dir df0:<return>' to the current line.
  185.  
  186.       $ set f1 dir
  187.  
  188.     would only add 'dir' you could then enter ' df0:<return>'
  189.  
  190.  
  191.  
  192. VIII. SHELL COMMANDS
  193.       ---------------
  194.   
  195.    First to start shell from a CLI
  196.     
  197.    shell [-a] [-c command;command]
  198.  
  199.    where:
  200.      -a disables all command line editing features. This is usefull for
  201.         when running shell over AUX:.
  202.    
  203.      -c allows execution of one command line and then exits out of shell.
  204.      This is usefull for running a internal shell commands in the 
  205.      background or from an external application. eg:
  206.         Run shell -c dir df0:; copy -r df0: df1: >nil:; echo "Done"
  207.  
  208.      If you 'Run' shell in the background without the -c switch shell
  209.      will detect this and imediatley exit.
  210.  
  211.  
  212.    Command execution:
  213.  
  214.    Internal shell commands maybe abreviated.
  215.  
  216.    The first argument is the command-name... if it doesn't exist in the
  217.    list below and isn't an alias, it is assumed to be an external (disk)
  218.    command. At this point the shell pathing, and AmigaDos pathing is checked
  219.    in order to locate the command.
  220.  
  221.    AUTOMATIC SOURCING may be accomplished by naming shell scripts with a
  222.    .sh suffix.  Thus, if you say 'stuff' and the file 'stuff.sh' exists in
  223.    your current or C: directory, it will be SOURCED with any arguments you
  224.    have placed in the $_passed variable. This is equivalent to typing 
  225.    'source stuff.sh'
  226.  
  227.  
  228.    Wild card expansions:
  229.     Most shell commands will accept multiple arguments that can
  230.     be as a result of wild card expansion. Also when the calling
  231.     an external command shell will first expand any wild cards
  232.     to seperate arguments. If you wish to have the external command
  233.     handle it's own wild carding you will need to insert quotes
  234.     arround the special wild card characters ? and *.
  235.  
  236.     eg.
  237.         arc a new.arc *.txt    - shell will expand and pass to arc
  238.         arc a new.arc "*.txt"   - let arc expand the wild cards.
  239.  
  240.     Wild card expansions:
  241.         ?      match any single character
  242.         *      match any string
  243.         df0:.../* all files in all directories on df0:
  244.         .../*      recursive search down ALL sub directories from
  245.               current level
  246.  
  247.     LIST OF COMMANDS:
  248.     -----------------
  249.  
  250.     *** NOTE: 
  251.     THERE EXISTS TWO VERSIONS OF SHELL 2.07M, THE ONLY DIFFERENCE
  252.     IS IN ONE VERSION COMMANDS CAT, RM, MV, HAVE BEEN RENAMED TO BE
  253.     TYPE, DELETE, RENAME. (I had'nt intended this version to be public
  254.     for consistancy sake, but it slip out.)
  255.     USE THE HELP COMMAND TO DETERMINE WHICH VERSION YOU HAVE.
  256.  
  257.  
  258.     ABORTLINE
  259.  
  260.     usage  : abortline
  261.     example: echo a;abort;echo b 
  262.     results: a
  263.  
  264.     Causes the rest of the line to be aborted. Intended for use in
  265.     conjunction with exception handling.
  266.  
  267.  
  268.     ALIAS
  269.  
  270.     Usage   : alias [name] [command string]
  271.     example : alias vt "echo Starting VT100;run sys:tools/vt100"
  272.  
  273.         Sets a name to be a string. You can alias a single name to a set 
  274.     of commands if you enclose them in quotes as above. By simply
  275.     typing vt, the command line above would be executed.
  276.  
  277.  
  278.     Argument Passing to an Alias:
  279.  
  280.     Usage    : alias name "%var [command string]"
  281.     example : alias xx "%q echo hi $q, how are ya."
  282.           xx Steve
  283.     results : hi Steve, how are ya.
  284.            
  285.     The second form of the alias command allows passing of arguments
  286.     to any position within the command string via use of a variable
  287.     name. To pass arguments to the end of a command string this method
  288.     is actually not necessary.
  289.  
  290.  
  291.     CAT
  292.     (TYPE)
  293.  
  294.        Usage   : cat [file file....]
  295.      example : cat foo.txt
  296.     
  297.     Type the specified files onto the screen.  If no file is specified,
  298.     STDIN in used.  CAT is meant to output text files only.
  299.  
  300.  
  301.     CD
  302.  
  303.     Usage   : cd [path]
  304.     example : cd df0:devs/printers
  305.  
  306.         Change your current working directory.  You may specify '..' to go
  307.     back one directory (this is a CD specific feature, and does not
  308.          work with normal path specifications).
  309.  
  310.         CD without any arguments displays the path of the directory you
  311.     are currently in.
  312.  
  313.  
  314.     COPY 
  315.  
  316.     Usage   : copy [-u][-d] file file
  317.     or    : copy [-u][-d] file1 file2...fileN dir
  318.     or    : copy [-r][-u][-d] dir1 dir2...dirN dir
  319.     options :
  320.           -r    recursive, copy all subdirectories as well.
  321.           -u    update, if newer version exist on dest, don't copy    
  322.           -d    don't set destination file date to that of source.
  323.  
  324.     example : copy -r df0: df1:
  325.  
  326.  
  327.           Copy files or directories. When copying directories, the -r option
  328.     must be specified to copy subdirectories as well.  Otherwise, only
  329.     top level files in the source directory are copied.
  330.  
  331.     All files will be displayed as they are copied and directory's 
  332.     displayed as they are created. This output can be suppessed by 
  333.     redirecting to nil: eg. copy -r >nil: df0: df1:
  334.  
  335.     Copy will abort after current file on Control-C.
  336.  
  337.          Copy by default sets the date of the destination file to that of
  338.          the source file. To overide this feature use the -d switch.
  339.  
  340.          Another useful option is the -u (update) mode were copy will not
  341.          copy any files which exists already in the destination directory
  342.     if the destination file is newer or equal to the source file.
  343.     This is usefull when developing code say in ram: eg. 'copy *.c ram:'
  344.     when done you can copy -u ram: df1: and only those modules you have 
  345.     modified will be copied back.
  346.  
  347.     Copy command will now create the destination directory if it does
  348.     not exist when specified as 'copy [-r] dir dir'. If you specify
  349.     copy file file file dir, then 'dir' must already exist.
  350.  
  351.  
  352.     DEC 
  353.  
  354.     Usage   : dec varname
  355.     example : dec abc
  356.  
  357.     Decrement the numerical equivalent of the variable and place 
  358.     the ascii-string result back into that variable.
  359.  
  360.  
  361.     DEVINFO 
  362.  
  363.     Usage   : devinfo [device: device:... ]
  364.     example : devinfo df0: df1: ram:
  365.  
  366.     Display Device statistics for the current device (CD base), or
  367.     specified devices. Gives block used/free, % used, errs and 
  368.     volume name.
  369.  
  370.  
  371.     DIR 
  372.  
  373.     Usage   : dir [-sdf] [path path ... ]
  374.     example : dir df0:
  375.     options :
  376.           -s  short multi(4) collum display, directories in red pen.
  377.           -d  list directories only
  378.           -f  list files only
  379.  
  380.  
  381.     Displays a directory of specified files. Default output show's 
  382.     date, protection, block size, byte size. And total space used.
  383.     Files are alphabetically sorted, first by upper case then by
  384.     lower. (allows README files ect.. to stand out.)
  385.     
  386.     Wild card expansions:
  387.         ?    match any single character
  388.         *    match any string
  389.         .../    recursive search down ALL sub directories
  390.         dir df0:.../    does a full (All) sorted directory
  391.         dir .../*.c    start at current dir and go down looking
  392.                 for all .c files.
  393.  
  394.     Exclude pattern matching specifier: !
  395.  
  396.     dir !*.info will       exclude all *.info files in current dir.
  397.     dir df0:.../!*.info       full directory tree of df0: but exclude
  398.                   any ugly .info files.
  399.     dir !*.o !*.c (will result in ALL files matching since what
  400.                 doesnt match the !*.o will match the !*.c)
  401.  
  402.  
  403.     ECHO
  404.  
  405.     Usage   : echo [-n] string
  406.      example : echo hi there
  407.     results : hi there
  408.  
  409.         Echo the string given. If -n switch given no newline is
  410.     appended.
  411.  
  412.  
  413.     ELSE ;
  414.  
  415.     Usage   : else ; command
  416.     Usage   : if -f foo.c ; else ; echo "Not there" ; endif
  417.  
  418.     Else clause, must follow an IF statement.
  419.  
  420.  
  421.     ENDIF
  422.  
  423.     Usage   : endif
  424.  
  425.     The end of an if statement. 
  426.  
  427.     *Note: if you return from a script file with unterminated IF's
  428.      and the last IF was false. No commands will be executed until
  429.      'endif' is typed.
  430.  
  431.  
  432.     FOREACH 
  433.  
  434.     Usage   : foreach varname ( strings ) command
  435.      example : foreach i ( a b c d ) "echo -n $i;echo \" ha\""
  436.     result  : a ha
  437.           b ha
  438.           c ha
  439.           d ha
  440.   
  441.     'strings' is broken up into arguments.  Each argument is placed in
  442.     the variable 'varname' in turn and 'command' executed.  To execute
  443.     multiple commands, place them in quotes:
  444.  
  445.     Foreach is especially useful when interpreting passed arguments in
  446.     an alias.
  447.     
  448.     eg.
  449.         foreach i ( *.pic ) viewilbm $i
  450.     assuming a.pic and b.pic in current directory the following commands
  451.     will occur:
  452.         viewilbm a.pic
  453.         viewilbm b.pic
  454.  
  455.    
  456.     FOREVER
  457.  
  458.     Usage   : forever command
  459.     or      : forever "command;command;command..."
  460.  
  461.     The specified commands are executed over and over again forever.
  462.  
  463.     -Execution stops if you hit ^C
  464.     -If the commands return with an error code.
  465.  
  466.  
  467.    GOTO 
  468.  
  469.     Usage   : goto label
  470.      example :  
  471.           label start
  472.             echo "At start"
  473.             dir ram:
  474.             goto start
  475.  
  476.     Goto the specified label name.  You can only use this command from a
  477.     source file. Labels may now be forward or reverse from current 
  478.     position.
  479.  
  480.  
  481.     HELP
  482.  
  483.     Usage   : help
  484.     example : help
  485.  
  486.     Simply displays all the available commands.  The commands are
  487.     displayed in search-order.  That is, if you give a partial name
  488.     the first command that matches that name in this list is the one
  489.     executed.  Generally, you should specify enough of a command so that
  490.     it is completely unique.
  491.  
  492.  
  493.     HISTORY 
  494.  
  495.     Usage   : history [partial_string]
  496.      example : history
  497.  
  498.     Displays the enumerated history list.  The size of the list is
  499.     controlled by the _history variable.  If you specify a partial-
  500.     string, only those entries matching that string are displayed.
  501.  
  502.  
  503.     IF
  504.  
  505.     Usage   : if argument conditional argument ;
  506.     or      : if argument
  507.      or      : if -f file
  508.  
  509.     If a single argument is something to another argument.  Conditional
  510.     clauses allowed:
  511.  
  512.     <, >, =, and combinations (wire or).  Thus <> is not-equal, >=
  513.     larger or equal, etc...
  514.  
  515.     If the left argument is numeric, both arguments are treated as
  516.     numeric.
  517.  
  518.     usually the argument is either a constant or a variable ($varname).
  519.  
  520.     The second form if IF is conditional on the existance of the argument.
  521.     If the argument is a "" string, then false , else TRUE.
  522.      
  523.     The third form of IF used by -f switch checks for existance of
  524.     the specified file.
  525.  
  526.     When using 'IF' command interactively if you are entering commands
  527.     following an 'IF' that was false, the prompt will be set to a
  528.     underscore '_ ' to indicate all commands will be ignored until
  529.     an 'ELSE' or 'ENDIF' command is seen.
  530.  
  531.     INC 
  532.  
  533.     Usage   : inc varname
  534.     example : inc abc
  535.  
  536.     Increment the numerical equivalent of the variable and place 
  537.     the ascii-string result back into that variable.
  538.  
  539.  
  540.     INPUT
  541.  
  542.     Usage   : input var var ... var
  543.     example : input abc
  544.  
  545.      Input from STDIN (or a redirection, or a pipe) to a variable.  The
  546.     next input line is placed in the variable.
  547.  
  548.  
  549.     LABEL
  550.  
  551.     Usage   : label name
  552.  
  553.     Create a program label right here. Used in source files, can then
  554.     GOTO a label.
  555.  
  556.  
  557.     MEM
  558.  
  559.     Usage   : mem
  560.     
  561.     Display current memory statistics for CHIP memory and
  562.     fast memory (if any installed).
  563.   
  564.  
  565.     MKDIR
  566.  
  567.     Usage   : mkdir name name name...
  568.      example : mkdir df0:stuff
  569.  
  570.     Create the specified directories.
  571.  
  572.  
  573.     MV 
  574.     (RENAME)
  575.  
  576.         Usage   : mv from to
  577.     or      : mv from from from ... from todir
  578.  
  579.     Allows you to rename a file or move it around within a disk.  
  580.     Allows you to move 1 or more files into a single directory.
  581.  
  582.  
  583.     PS
  584.  
  585.      Usage   : ps
  586.     
  587.     Gives status of DOS processes.  eg: 
  588.       
  589.     Proc Command Name         CLI Type    Pri.  Address  Directory
  590.      1   SHELL                Initial CLI   0      97b0  Stuff:shell
  591.      2   sys:c/clockmem       Background  -10    2101a8  Workdisk:
  592.      3   c:emacs              Background    0    212f58  Stuff:shell
  593.      4   sys:c/VT100          Background    0    227328  Workdisk:
  594.     
  595.      Address is the addres of the task, directory is the process
  596.      currently CD'd directory.
  597.  
  598.  
  599.     PWD
  600.     
  601.     Usage   : pwd
  602.  
  603.     Rebuild _cwd by backtracing from your current directory.
  604.  
  605.  
  606.     QUIT
  607.  
  608.     Usage   : quit
  609.  
  610.     Quit out of Shell back to CLI.
  611.  
  612.  
  613.     RETURN
  614.  
  615.     Usage   : return [n]
  616.     example : return 10
  617.  
  618.     Exit from a script file, or quit from shell with optional
  619.     exit code.
  620.  
  621.  
  622.     RM
  623.     (DELETE)
  624.  
  625.      Usage   : rm [-r] file file file...
  626.     example : rm foo.txt test.c
  627.     
  628.     Remove (delete) the specified files.  Remove always returns
  629.         errorcode 0.  You can remove empty directories.  The '-r' option
  630.         will remove non-empty directories by recursively removing all sub
  631.         directories.
  632.     If  you specify any wildcard deletes the files will be listed as
  633.     they are deleted. This can be suppressed by redirecting to nil: 
  634.     eg.  rm df0:.../*.o   delete all .o files from every directory.
  635.  
  636.  
  637.     RUN
  638.  
  639.     Usage   : run prgm
  640.     example : run emacs
  641.  
  642.     Finds the specified file via $_path variable, or 2nd via AmigaDos
  643.     PATH setting, then calls AmigaDos Run command with the explicit
  644.     path/command. This command is really only implemented to allow
  645.     consistancy in first checking the shell pathing before amigados
  646.     pathing. Since shell allows for device names in _path it does'nt
  647.     care when you swap disks; if you had "df0:c/" in _path then whatever
  648.     disk you have in df0: will be checked. AmigaDos PATH always resolves
  649.     to a Lock that points only to a particular disk label:directory.
  650.  
  651.  
  652.     SET
  653.   
  654.     Usage   : set [name] [string]
  655.     example : set abc hello
  656.  
  657.     Set with no args lists all current variable settings.
  658.     Set with one arg lists the setting for that particular variable.
  659.     Specifying name and string, stores the string into variable name.
  660.  
  661.         Also See the section on special _variables.
  662.  
  663.  
  664.     SLEEP 
  665.  
  666.     Usage   : sleep timeout
  667.     example : sleep 10
  668.  
  669.     Sleep for 'timeout' seconds, or until ^C typed.
  670.   
  671.  
  672.     STRHEAD  
  673.  
  674.     Usage   : strhead varname breakchar string
  675.      example : strhead j . foobar.bas
  676.               echo $j
  677.     result    : foobar
  678.  
  679.     Remove everything after and including the breakchar in 'string' and
  680.         place in variable 'varname'.
  681.  
  682.  
  683.     STRTAIL  
  684.     
  685.     Usage   : strtail varname breakchar string
  686.      example : strtail j . foobar.bas
  687.           echo $j
  688.     result  : bas
  689.  
  690.     Remove everything before and including the breakchar in 'string' and
  691.     place in variable 'varname'.
  692.  
  693.  
  694.     SOURCE 
  695.  
  696.     Usage   : source file [arguments]
  697.     example : source do_assigns all
  698.     result  : source file 'do_assigns' called with var _passed = 'all' 
  699.  
  700.     Execute commands from a file.  You can create SHELL programs in
  701.     a file and then execute them with this command.  Source'd files
  702.     have the added advantage that you can have loops in your command
  703.     files (see GOTO and LABEL).  You can pass SOURCE files arguments
  704.     by specifying arguments after the file name.  Arguments are passed
  705.     via the _passed variable (as a single string).
  706.  
  707.     Automatic 'sourcing' is accomplished by placing a .sh extension on
  708.     the file and executing it as you would a C program:
  709.  
  710.  
  711.     --------- file hello.sh ---------
  712.     foreach i ( $_passed ) "echo yo $i"
  713.     ---------------------------------
  714.  
  715.     $ hello a b c
  716.     yo a
  717.     yo b
  718.     yo c
  719.  
  720.  
  721.     UNALIAS
  722.  
  723.     Usage   : unalias name .. name
  724.     example : unalias vt
  725.  
  726.     Delete aliases..
  727.  
  728.  
  729.     UNSET
  730.  
  731.     Usage   : unset name .. name
  732.      example : unset abc
  733.  
  734.           Unset one or more variables.  Deletes them entirely.
  735.  
  736.  
  737.     VER
  738.  
  739.     Usage   : ver
  740.       
  741.     Show current version name, & authors. 
  742.  
  743.  
  744.  
  745. IX. SPECIAL SET VARIABLES
  746.     ---------------------
  747.  
  748.     _prompt
  749.     This variable is set to the command you wish executed that will
  750.     create your prompt. This can contain escape sequences if you wish.
  751.     The if command will set the prompt to a '_ ' if commands are
  752.     disabled while waiting for a 'endif' or 'else' command. Interactive
  753.      mode only.
  754.  
  755.     _history
  756.         This variable is set to a numerical value, and specifies how far
  757.         back your history should extend.
  758.  
  759.     _debug
  760.         Debug mode... use it if you dare.  must be set to some value
  761.  
  762.     _verbose
  763.         Verbose mode (for source files).  display commands as they are
  764.         executed.
  765.  
  766.     _maxerr
  767.         The worst (highest) return value to date.  To use this, you usually
  768.         set it to '0', then do some set of commands, then check it.  
  769.  
  770.     _lasterr
  771.         Return code of last command executed.  This includes internal
  772.         commands as well as external comands, so to use this variables
  773.         you must check it IMMEDIATELY after the command in question.
  774.  
  775.     _cwd
  776.         Holds a string representing the current directory we are in from
  777.         root.  The SHELL can get confused as to its current directory if
  778.         some external program changes the directory.  Use PWD to rebuild
  779.         the _cwd variable in these cases.
  780.  
  781.     _passed
  782.         This variable contains the passed arguments when you SOURCE a file
  783.         or execute a .sh file.  For instance:
  784.  
  785.         test a b c d
  786.  
  787.         -------- file test.sh ----------
  788.         echo $_passed
  789.         foreach i ( $_passed ) "echo YO $i"
  790.         --------------------------------
  791.  
  792.  
  793.     _path
  794.         This variable contains the search path when the shell is looking
  795.         for external commands.  The format is:  DIR,DIR,DIR  Each DIR must
  796.         have a trailing ':' or '/'.  The current directory is always
  797.         searched first.  The entire path will be searched first for the
  798.         <command>, then for <command>.sh (automatic shell script sourcing).
  799.  
  800.         The default _path is set to  "c:,df1:c/,df0:c/,ram:,ram:c/"
  801.         When using 'run' command Shell will now use it's own search
  802.     path first to find the command to run. If it fails to find
  803.     the command (but the Run command was found) it executes the
  804.     command line anyway to let amigaDos search path take over.
  805.  
  806.     _insert
  807.         Set's the default for insert/overtype mode for command line
  808.     editing. ^A toggles between, but after <RET> the default is 
  809.         set back as indicated by this variable. By default _insert is 1
  810.         indicating insert mode on setting to zero will make overtype
  811.     the default.
  812.  
  813.     _width
  814.     Indicates the console window width, 77 if unset. 
  815.      Will change automatically if the user resizes the window.
  816.     
  817.  
  818.  
  819. X.  ADVANCED TOPICS
  820.     ---------------
  821.  
  822.     EXCEPTION_PROCESSING:
  823.  
  824.     if no _except variable exists, any command which fails causes the
  825.     rest of the line to abort as if an ABORTLINE had been executed.  If
  826.     the _except variable exists, it is of the form:
  827.  
  828.     "nnn;commands..."
  829.  
  830.     where nnn is some value representing the minimum return code required
  831.     to cause an error.  Whenever a command returns a code which is
  832.     larger or equal to nnn, the commands in _except are executed before
  833.     anything.  WHEN _except EXISTS, THE COMMAND LINE DOES NOT ABORT
  834.     AUTOMATICALLY.  Thus, if you want the current line being executed
  835.     to be aborted, the last command in _except should be an "abortline".
  836.  
  837.     exception handling is disabled while in the exception handling routine
  838.     (thus you can't get into any infinite loops this way).
  839.  
  840.     Thus if _except = ";", return codes are completely ignored.
  841.  
  842.     example:
  843.  
  844.     set _except "20;abortline"
  845.  
  846.  
  847.  
  848. XI. EXAMPLE .login file
  849.     -------------------
  850.  
  851.     from a CLI or the startup-script say 'SHELL filename'.  That file
  852.     is sourced first.  thus, 'SHELL .login' will set up your favorite
  853.     aliases:
  854.  
  855.  
  856.     # -Steve's .login file- #
  857.  
  858.     echo -n    "Enter Date [DD-MMM-YY HH:MM] ";input new; DATE $new
  859.  
  860.     # ------My search path ------- #
  861.  
  862.     set   _path  ram:c/,ram:,c:,df0:c/,df1:c/,sys:system/,sys:utilities
  863.  
  864.     # -------Function keys-------- #
  865.  
  866.     set   f1     dir df0:^M
  867.     set   f2     dir df1:^M
  868.     set   F1     dir -s df0:^M
  869.     set   F2     dir -s df1:^M
  870.     set   f3     info^M
  871.     set   f4     ps^M
  872.  
  873.     # ---------Quickies---------- #
  874.  
  875.     # -query delete- #
  876.     #another favorite eg    qd *.c
  877.     alias qd "%q foreach i ( $q ) \"echo -n Delete [n] ;input a;if $a = y;del $i;endif\""
  878.  
  879.     alias delete rm
  880.     alias rename mv
  881.     alias makedir mkdir
  882.     alias type  cat
  883.     alias print "%q copy $q prt:"
  884.     alias info  "devinfo df0: df1: ram:"
  885.     alias tosys "assign c: SYS:c"
  886.     alias toram "assign c: RAM:c;"
  887.     alias tomanx "assign c: MANX:c; manxinit"
  888.     alias d     "dir -s"
  889.     alias clr   "echo -n ^l"
  890.     alias wb    "loadwb"
  891.     alias pref  "sys:preferences"
  892.     alias cal   "run sys:utilities/calculator"
  893.  
  894.     # ------Applications---------- #
  895.  
  896.     alias em    "run emacs"
  897.     alias vt    "run sys:c/VT100"
  898.  
  899.     # --------Finish Up----------- #
  900.  
  901.     ver ;echo -n "Shell loaded on ";date
  902.  
  903.  
  904.  
  905. XII. Example Source file
  906.      -------------------
  907.  
  908.      # ---- MANXINIT.SH  ------ #
  909.  
  910.     SET INCLUDE=AC:include CCTEMP=ram:
  911.     makedir ram:lib;Set CLIB=RAM:lib/;copy AC:lib/$libfile ram:lib"
  912.     alias    cleanup    "del >NIL: ram:lib/* ram:lib"
  913.  
  914.     #run make in background at lower priority:
  915.     alias    make    "%q run ChangeTaskPri -5 +^J^J MAKE $q"
  916.  
  917.