DESIGN OUTLINE for CSCI-e215 Assignment 5
Russell J Lowke

    smsh.c
    
      AUTHOR: Russell Lowke
   CSCIE-215: Assignment Five

       Usage: smsh [script file name]

  [var]=[value]  Assigns an internal var to a value
            set  prints a list of all saved values
         export  exports a value
   exit [value]  exits smsh with [value]
     read [var]  reads into [var] an assignment input from the keyboard
  cd [pathname]  changes the current working directory
  if [list ;then list ... [;else list] ;fi]
                 Executes the list following if and, if it returns a 0
                 (zero)exit status, executes the list following the first
                 then. Otherwise, the else list is executed.

 Description: Create a Unix shell that allows users to manage processes
              such as running programs and controlling input.
              The shell has its own scripting language with variables and
              if statements.

      Method: Main reads from file or stdin, taking input and sending it to
              splitline (splitline.c) to have variables substituted and to
              be parsed into arguments.  varlib (varlib.c) is used to keep 
              track of all variables added by the user, and to 
              get unix environment vars.
              Once arguments have been isolated they are sent to
              handleCommand to be processed by an appropriate function,
              in most cases a command is external, in which case it is
              handled by execute(), who forks and exec's the command.
              handleCommand also deals with IF related statements, keeping
              careful track of their progress and only allowing the
              correct then/else blocks to be processed.

              
              smsh.c methods:

                main - main checks for a script file for input, otherwise
                       uses stdin input. the loop reads input line by line.  
                       Each line has variables ($VAR)subsititued, then
                       is split into its individual arguments.
                       Finally, the arg count and all args are pased into
                       handleCommand() which returns a state. If this state
                       is != NORMAL on exit then there is a
                       scripting bug ("no fi")
               setup - All initialization goes here.
       handleCommand - Works out where to pass the args to.
                       Internal commands are set to their own specific
                       function, external commands are delt with by execute().
                       More importantly, handleCommand deals with the 
                       possibility of if statements, by use of an 'ifState'
                       var.  This var keeps track of the progress of the
                       if statement.  HandleCommand returns the ifState,
                       which main needs, in case it reaches EOF without
                       a concludeing fi.
               fatal - Fatal error message to stderr then exit (never returns)
        gracefulExit - cleanup smsh before exiting
    get_next_command - read next line from input_stream.  Return FALSE on EOF
             execute - execute commands in argv.
                       Uses fork to make a child duplicate to exe
                       if sucessful exe will exit itself. information of
                       child is held in child_info
             readCmd - Assigns internal var [varname] equal to keyboard input
         getKeyInput - Reads input from the keyboard, placing it in buffer
               cdCmd - cd command, calls chdir with a path.
              report - Report of important vars in info from child
                       Good for debugging, this function is not used by smsh


              splitline.c methods:
              
              splitline contains fuctions to parse strings and general string
              handling, also has fuctions to check for valid variable names.

              
           splitline - parse line [cmdline] into an array of strings
                       cmdline has a string of white-space separated tokens
                       put the addresses of the tokens in the array argv[]
                       put their number in *argcp and do not put more than max
                       in argv or suffer dire consequences!
                       NOTE: this modifies cmdline
                       returns FALSE on too many args or zero args.
                       TRUE for ok stuff
      substituteVars - search through original string [orgStr] looking for
                       embeded vars ('$') and backslash ('\\').  
                       In case of backslash read the next char 'as is',
                       otherwise, in case of viarable, substitute in the
                       variables value.
                       Put the result into new string [newStr].
        validVarName - Test string [varName] to see if it is a legal variable
                       name. Done primarily using isValidVarChar - but also
                       tests for 1st char not being a number
      isValidVarChar - Check if a char [c] is considered legal when in a
                       variable name.
                       Legal values are: numbers from 0 through 9
                                        A - Z, a - z, and underscore.

       Notes: VLtable2environ in execute() calls malloc, but memory is
              free()d with exec
