BASH description

Bash is Copyright (C) 1989, 1991 by the Free Software Foundation, Inc.

Bash is an sh-compatible command language interpreter that executes com- mands read from the standard input or from a file. Bash also incorporates useful features from the Korn and C shells (ksh and csh).

Bash is ultimately intended to be a conformant implementation of the IEEE Posix Shell and Tools specification (IEEE Working Group 1003.2).

We have been forced to deal with two bash operations : Command Execution and TAB completion. The following is mostly taken from Bash manual.

I. Command Execution.

  After a command has been split into words, if it results in a simple com-
  mand and an optional list of arguments, the following actions are taken.

  If the command name contains no slashes, the shell attempts to locate it.
  If there exists a shell function by that name, that function is invoked as
  described above in FUNCTIONS.  If the name does not match a function, the
  shell searches for it in the list of shell builtins.  If a match is found,
  that builtin is invoked.

  If the name is neither a shell function nor a builtin, and contains no
  slashes, bash searches each element of the PATH for a directory containing
  an executable file by that name.  If the search is unsuccessful, the shell
  prints an error message and returns a nonzero exit status.

  If the search is successful, or if the command name contains one or more
  slashes, the shell executes the named program.  Argument 0 is set to the
  name given, and the remaining arguments to the command are set to the argu-
  ments given, if any.

  If this execution fails because the file is not in executable format, and
  the file is not a directory, it is assumed to be a shell script, a file
  containing shell commands.  A subshell is spawned to execute it.  This sub-
  shell reinitializes itself, so that the effect is as if a new shell had
  been invoked to handle the script, with the exception that the locations of
  commands remembered by the parent (see hash below under SHELL BUILTIN COM-
  MANDS) are retained by the child.

  If the program is a file beginning with #!, the remainder of the first line
  specifies an interpreter for the program.  The shell executes the specified
  interpreter on operating systems that do not handle this executable format
  themselves.  The arguments to the interpreter consist of a single optional
  argument following the interpreter name on the first line of the program,
  followed by the name of the program, followed by the command arguments, if
  any.



  All that is implemented in source file execute_cmd.c and this is the file
  we had to patch to allow tftp command executions, or more exactly 
  execution of commands with remote file arguments.


II. TAB Completion.

  That option is implemented with help of READLINE.

  This is the library that handles reading input when using an interactive
  shell, unless the -nolineediting option is given.  By default, the line
  editing commands are similar to those of emacs.  A vi-style line editing
  interface is also available.

  Completion options of READLINE are :

  complete (TAB)
       Attempt to perform completion on the text before point.  Bash attempts
       completion treating the text as a variable (if the text begins with
       $), username (if the text begins with ~), hostname (if the text begins
       with @), or command (including aliases and functions) in turn.  If
       none of these produces a match, filename completion is attempted.
  possible-completions (M-?)
       List the possible completions of the text before point.
  insert-completions
       Insert all completions of the text before point that would have been
       generated by possible-completions.  By default, this is not bound to a
       key.
  complete-filename (M-/)
       Attempt filename completion on the text before point.
  possible-filename-completions (C-x /)
       List the possible completions of the text before point, treating it as
       a filename.
  complete-username (M-~)
       Attempt completion on the text before point, treating it as a user-
       name.
  possible-username-completions (C-x ~)
       List the possible completions of the text before point, treating it as
       a username.
  complete-variable (M-$)
       Attempt completion on the text before point, treating it as a shell
       variable.
  possible-variable-completions (C-x $)
       List the possible completions of the text before point, treating it as
       a shell variable.
  complete-hostname (M-@)
       Attempt completion on the text before point, treating it as a host-
       name.
  possible-hostname-completions (C-x @)
       List the possible completions of the text before point, treating it as
       a hostname.
  complete-command (M-!)
       Attempt completion on the text before point, treating it as a command
       name.  Command completion attempts to match the text against aliases,
       reserved words, shell functions, builtins, and finally executable
       filenames, in that order.
  possible-command-completions (C-x !)
       List the possible completions of the text before point, treating it as
       a command name.
  dynamic-complete-history (M-TAB)
       Attempt completion on the text before point, comparing the text
       against lines from the history list for possible completion matches.
  complete-into-braces (M-{)
       Perform filename completion and return the list of possible comple-
       tions enclosed within braces so the list is available to the shell
       (see Brace Expansion above)
In our project we had to patch source file bashline.c which functions are executed from readline functions such as readline_complete(). Every TAB completion in shell goes through attempt_shell_completion() in bashline.c.

romm@empire.tau.ac.il
Last modified: Tue Oct 15 05:18:41 1996