home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-386-Vol-2of3.iso / c / csh4.zip / SHELL.DOC < prev    next >
Text File  |  1985-09-05  |  16KB  |  462 lines

  1.         shell.exe 
  2.  
  3.         command processor for ms.dos 
  4.  
  5.         This is  yet  another  command.com  replacement.    It implements
  6.         unix-like shell commands (ls, mv, fgrep, rm, chdir,  chmod)  etc.
  7.         Other features include: 
  8.  
  9.         1. Command line expansion of ambiguous file names.  
  10.  
  11.         Programs  invoked  from  shell   never see '*.*' as an argument -
  12.         they see  the  list  of  all  matching  files  in    the  current
  13.         directory.  
  14.  
  15.         2. History substitution - ala C-shell.  
  16.  
  17.         History substitution is a powerful means to save retyping of long 
  18.         command lines.It allows you to do things like re-execute the last 
  19.         command,  re-execute  the  last  command but redirect output to a
  20.         file, or execute a  new  command  with  arguments  from  previous
  21.         command  lines.    The  last  20  commands  are saved, and can be
  22.         reviewed by typing the 'history' command.  
  23.  
  24.         Previous commands can be referred to by their number, or relative 
  25.         to the  current  command's  number.    Parameters  from  previous
  26.         commands can be seperated out and used individually.  
  27.  
  28.         History  substitutions  specifications  come  in  two parts - the
  29.         command number  specifier and the argument  specifier,  seperated
  30.         by a  colon.    The  argument    specifier  is optional; if it is
  31.         omitted, the entire command line is specified.  
  32.  
  33.             <command specifier> ::= !! | !n | !-n 
  34.             !!  = last command
  35.             !n  = nth command
  36.             !-n = command n commands before current command number
  37.  
  38.             <argument specifier> ::= :[^$*] | :n | :n* | <empty>
  39.             n   = number of argument (0 being the command name)
  40.             ^   = first argument (i.e. argv[1])
  41.             $   = last argument
  42.             *   = ^-$, or nothing if only one word on command line
  43.             n*  = arguments n through $
  44.  
  45.             <history subst specification> ::= <command specifier><argument specifier>
  46.  
  47.         This is not as complicatated as  it  may  appear.    Here  is  an
  48.         example session.  
  49.  
  50.             0% ls *.c
  51.             *.c
  52.             foo.c bar.c
  53.             1% more foo.c
  54.             /* edit the last argument of the last command */
  55.             2% edit !!:$            
  56.             /* go off and edit */
  57.             /* reference last argument of last command */
  58.             3% fgrep foo !!:$ bar.c 
  59.             FOO.C : foo
  60.             BAR.C : foo
  61.             /* edit the second thru the last args of command 3 */
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.             4% edit !3:2*            
  71.             (go off and edit)
  72.             /* repeat last command */
  73.             %5 !!
  74.             (go off and edit)
  75.             /* remove the 1st argument of the command 2 before the current one */
  76.             %6 rm !-6:^
  77.  
  78.         History  substitution here is a compatible subset of the C-shells
  79.         history substitution  facility.    Cshell  allows  even   weirder
  80.         combinations.  
  81.  
  82.         3.  Multiple  commands  on  one  command line - Command lines are
  83.         split at  semicolons.  
  84.  
  85.         example 
  86.  
  87.             %0 ls -l *.c ; make shell.exe ; exit
  88.  
  89.         4. Character escapes and argument quoting - i.e.  '\;' suppresses 
  90.         the command  parser  from  seeing  the  semicolon  as  a  command
  91.         seperator.  
  92.  
  93.         Quotes are handles thusly: 
  94.  
  95.             1.  String  surrounded  by  single quotes are stripped of the
  96.             single quotes, and passed without wild-card expansion to  the
  97.             invoked program.  
  98.  
  99.             2.  Strings  surrounded  by double quotes are passed complete
  100.             with quotes to the calling program.   This  was  done  for  a
  101.             version  of grep that I have that accepts regular expressions
  102.         with embedded blanks within double quotes.  
  103.  
  104.         5. Many builtin commands.  
  105.  
  106.             a:              b:              c:              cat             
  107.             cd              chdir           chmod           cls             
  108.             commands        copy            cp              copy            
  109.             d:              del             dir             e:              
  110.             echo            era             erase           error           
  111.             exit            f:              fgrep           g:              
  112.             h:              hist            history         i:              
  113.             j:              ls              md              mkdir           
  114.             more            mv              no history      popd            
  115.             pushd           pwd             rd              rm              
  116.             rmdir           set             tee             touch           
  117.             y               
  118.  
  119.         There are many that are simply aliases, e.g.    'copy'  and  'cp'
  120.         invoke the same program.  
  121.  
  122.         6. commands description syntax 
  123.  
  124.             terms used in syntax explanations :
  125.             
  126.             fname ::= PC-DOS ambiguous or unambiguous file or directory name.
  127.             
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.             uname ::= unambiguous PC-DOS file or directory name
  137.             
  138.             string ::= any string of printable characters of arbitrary(<512) length.
  139.             
  140.             filelist ::= filename [filename .. filename]
  141.             
  142.             noargs ::= no arguments at all
  143.             
  144.             {arg} ::= term is optional
  145.             
  146.             envstring ::=    <string>=<string> 
  147.  
  148.         7. command syntax 
  149.  
  150.         drive
  151.             a: | b: | c: | d: | e: | f: | g: | h: | i: | j: <noargs> 
  152.  
  153.             changes default  drive.    If  you  don't  have such a drive,
  154.             nothing happens.  
  155.  
  156.         cat
  157.             cat {<filelist>} 
  158.  
  159.             copies specified files to  standard  output.    If  none  are
  160.             given, copies standard input to standard output 
  161.  
  162.         cp
  163.             cp | copy <filelist> <uname> 
  164.  
  165.             copies specified  files  to  destination  file or device.  If
  166.             more than one file is in the file list,  <uname>  must  be  a
  167.             directory.  
  168.  
  169.         cd
  170.             cd | chdir <dirname> 
  171.  
  172.             makes <dirname> the current default directory.  
  173.  
  174.         chmod
  175.             chmod {-|+[rwh]*} <filelist> 
  176.  
  177.             change file permissions for specified files 
  178.  
  179.             +r, -r turn on or off read permission - i.e. hide the file.
  180.             +w, -w turn on or off write permission.
  181.             +h, -h turn on or off hidden attribute - converse of r
  182.             +a, -a turn on or off archive attribute
  183.  
  184.             Note  that '-r' or '+rwh' are both valid syntax for switches.
  185.             Also new permission switches  are  permissable  between  file
  186.             names  with  the  following  warning: I don't reset the masks
  187.             between file names - if you have a second batch of  attribute
  188.             changes on  the  command  line,  the  effect is additive.  If
  189.             you're not  careful,  you  could  make  a  mess  of  a  files
  190.             attributes.  
  191.  
  192.             If  you don't specify any attribute switches, file attributes
  193.             will be set  to  0,  which  means  read,write,not  hidden,not
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.             system, not  modified since last backup.  
  203.  
  204.         cls
  205.             cls | clear <noargs> 
  206.  
  207.             clears the screen and homes the cursor.  
  208.  
  209.         commands
  210.             commands <noargs> 
  211.  
  212.             prints a table of available built-in commands.  
  213.  
  214.         del
  215.             del 
  216.  
  217.             synonym for rm.  
  218.  
  219.         dir
  220.             dir 
  221.  
  222.             synonym for ls.  
  223.  
  224.         echo
  225.             echo <anything> 
  226.  
  227.             echos argument list to screen.  
  228.  
  229.         era
  230.             era 
  231.  
  232.             synonym for rm.  
  233.  
  234.         error
  235.             error <noargs> 
  236.  
  237.             prints returned value of last command to the screen.  
  238.  
  239.         exit
  240.             exit <noargs> 
  241.  
  242.             terminates execution of the shell.  
  243.  
  244.         fgrep
  245.             fgrep <pattern> <filelist> 
  246.  
  247.             looks for unambiguous pattern <pattern> in <filelist>.  echos 
  248.             lines matching to the screen.  
  249.  
  250.         hist
  251.             hist | history <noargs> 
  252.  
  253.             prints history list to standard output.  
  254.  
  255.         ls
  256.             ls | dir {-[alqcr]} <filelist> 
  257.  
  258.             Lists files that match <filelist> 
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.             -a all  files,  including  system  files are listed.  '.' and
  269.             '..' are suppressed, but you know they're there if  you  need
  270.             them, don't you?  
  271.             -l prints out file times, permissions, etc 
  272.             -q suppresses header line from display - useful when you want 
  273.             to pipe stuff into another program.  
  274.             -c print as one column.  
  275.             -r recurse through all encountered subdirectories.  
  276.  
  277.         md
  278.             md | mkdir <uname> 
  279.  
  280.             make a directory.  Prints an error if it can't be done 
  281.  
  282.         more
  283.             more {-[0-9]*} {<filelist>} 
  284.  
  285.             List file to screen with pauses 
  286.  
  287.             -n  specify  tab  width  when  expanding  tabs, where n is an
  288.             integer.  more acts like 'cat'  when  redirected  -  you  can
  289.             concatenate files  in this manner.  If no files are specifed,
  290.             standard input is 'mored.' 
  291.  
  292.         mv
  293.             mv <filelist> <uname> 
  294.  
  295.             moves specified file or files to target specifed by  <uname>.
  296.             If  there  is  more  than one file in list, <uname> must be a
  297.             directory 
  298.  
  299.         popd
  300.             popd <noargs> 
  301.  
  302.             returns to directory at top of directory stack.  
  303.  
  304.         pushd
  305.             pushd <uname> 
  306.  
  307.             save  current  working  directory  on  directory  stack,  and
  308.             changes current working directory to <uname>.  
  309.  
  310.         pwd
  311.             pwd 
  312.  
  313.             prints current working directory to standard output.  
  314.  
  315.         rd
  316.             rd | rmdir <uname> 
  317.  
  318.             remove specified directory if possible.  
  319.  
  320.         rm
  321.             rm {-q} <filelist> 
  322.  
  323.             blows  away all files in <filelist>. If -q is specified, will
  324.             ask if they should be removed.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.         set
  335.             set {<envstring> {<envstring> .. <envstring>}} 
  336.  
  337.             sets a string in the environment.   If  you  specify  'name='
  338.             with   no   string   after,   it  will  remove  it  from  the
  339.             environment.  If you don't specify a string, set  prints  out
  340.             current environment.  
  341.  
  342.         tee
  343.             tee <uname> 
  344.  
  345.             Copies  standard  input to standard output, depositing a copy
  346.             in <uname> 
  347.  
  348.         touch
  349.             touch <filelist> 
  350.  
  351.             Makes the modification time of specified  files  the  current
  352.             date and time.  
  353.  
  354.         y
  355.             y <filelist> 
  356.  
  357.             copies standard input to standard output, and then copies the 
  358.             specified files  to standard output.  Sort of the opposite of
  359.             tee, in other words.  
  360.  
  361.         7. Helpful hints 
  362.  
  363.             Use forward slashes in all path names - they get converted to 
  364.             back slashes before  dos  hears  about  them.    If  you  are
  365.             invoking a program that expects forward slashes (dos external 
  366.             commands frinstance) precede it with a back slash.  
  367.  
  368.             put  single  quotes around arguments with semicolons in them,
  369.             so they don't turn into command delimiters.  
  370.  
  371.             The set command affects only the local  shell's  environment.
  372.             You can 'exit' to command.com and the original environment is 
  373.             intact.   The  local  environment  is  4K  large  -  which is
  374.             useful.  
  375.  
  376.             Exit and re-invoke if you have trouble loading large programs 
  377.             from it - shell dynamically allocates and  frees  memory  all
  378.             the  time,  but the AZTEC run-time doesn't tell DOS to shrink
  379.             memory 
  380.  
  381.         8. Implementation notes 
  382.  
  383.             DOS doesn't acknowledge  a  'change  default  drive'  command
  384.             until you issue  a  'get  current directory' call.  Why?  The
  385.             only way I figured this out is by disassembling command.com.  
  386.  
  387.             This was developed with AZTEC C by MANX.  In  it  are  a  few
  388.             hacked  up  pieces  of  AZTECS library source, which I hereby
  389.             acknowledge.  If MANX has  a  problem  with  me  distributing
  390.             them,  they  can  call  me direct - I figure I'm doing them a
  391.             favor by disseminating this program  as  an  example  of  the
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.             power and quality of their compiler and development tools.  
  401.  
  402.             If  you  have  the AZTEC compiler and MANX's version of make,
  403.             you can recreate the shell  from  source,  by  using  arc  to
  404.             unpack everything into a directory, editing the macros BINDIR 
  405.             and CLIB  and then making  shell.com.  I wouldn't try it with
  406.             any other compiler, because I make a lot of  calls  to  AZTEC
  407.             specific routines.    You can write your own commands and add
  408.             them  by  editing  cmds.c,  and  putting  the  name  of  your
  409.             subroutine and its associated command string into the builtin 
  410.             array.   
  411.  
  412.             You  can  safely  modify  any  of my builtins, as long as you
  413.             don't assume that all of your static variables are  going  to
  414.             stay initialized to startup values.  
  415.  
  416.             Any  of the other code (main.c, fexecvp.c fexecv.c) modify at
  417.             your own peril.  I break them every time I do it, and I wrote 
  418.             them!!!  
  419.  
  420.             PC|MS-DOS has a limit of 20 file  handles.    If  you  add  a
  421.             command  that opens files, make sure you catch the ctrl-break
  422.             signal and close them.  Look at CAT.C or Y.C for examples.  
  423.  
  424.         9. BUGS 
  425.             External DOS commands have trouble parsing the  command  line
  426.             when invoked from   shell.  The command line gets garbled.  I
  427.             spent a lot of time trying to figure this problem out  to  no
  428.             avail.  They apparently get their command line arguments some 
  429.             way that  is a mystery to me.  The only solution is either to
  430.             either run command.com, or 'exit'  to  the  original  command
  431.             prompt.  
  432.  
  433.             This  problem  has  kept  me  from running this as a straight
  434.             command.com   replacement.    It  just  goes  to  show   that
  435.             Microsoft and IBM have one hell of a time following their own 
  436.             rules.  
  437.  
  438.             Programs  compiled  by  AZTEC  C  that don't set up their own
  439.             signal  handlers  seem  to  be  'unbreakable'  -  you   can't
  440.             ctrl-break  out  of  them, as though SIGINT is set to SIG_IGN
  441.             before entry.  You might not want to invoke such a program if 
  442.         it lasts hours and you want to be able to break out of it.  
  443.  
  444.         QUESTIONS COMMENTS GOTO 
  445.         KENT WILLIAMS
  446.         NORAND INC.
  447.         550 2nd ST. S.E.
  448.         Cedar Rapids Iowa 52401
  449.         (319) 338-6053 (HOME VOICE)
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.