Simple commands

A simple command is a sequence of optional variable assignments and redirections followed by a command name. When a simple command is recognized by qsh, it performs the following actions:

  1. Leading words of the form name=value are stripped off and assigned to the environment of the simple command. Redirection operators and their arguments are saved for processing in step 3.
  2. The remaining words are expanded as described in Word expansions, and the first remaining word is considered the command name. Any additional words are considered the arguments of the command. If no command name is found, then the name=value variable assignments recognized in step 1 affect the current shell.
  3. Redirections are performed as described in Redirection.
Path search

If a simple command does not contain any slashes, qsh finds the command by searching:

  1. for a special built-in utility of that name, then
  2. for a shell function of that name, then
  3. for a regular built-in utility of that name, then
  4. each directory in the PATH variable in turn for the regular utility.

Command names containing a slash (/) are run as a regular utility without performing any of the above searches.

A built-in utility is run internal to the shell, without starting a new process. A special built-in utility is different from a regular built-in utility in these respects:

  1. A syntax error in a special built-in utility causes a non-interactive shell to exit.
  2. Variable assignments specified with a special built-in utility remain in effect after the utility completes.

These are the special built-in utilities: break, colon, continue, declare, dot, eval, exec, exit, export, local, readonly, return, set, shift, source, trap, typeset, and unset.

When a shell function is run, all of the shell positional parameters (except the special parameter 0, which remains unchanged) are set to the arguments of the shell function. The variables which are explicitly placed in the environment of the command (by placing assignments to them before the function name) are made local to the function and are set to the specified values. The positional parameters are restored to their original values when the shell function completes.

When a regular utility is run, qsh starts a new process, passing the arguments and the environment to the program. If the program is a shell script, qsh will interpret the program in a subshell. qsh will reinitialize itself in this case, so that the effect will be as if a new shell had been invoked to handle the shell script.

Command exit status

Each command has an exit status that can influence the behavior of other shell commands. By convention, a command exits with zero for normal or success, and non-zero for failure, error, or a false indication. The documentation for each command describes the exit codes it returns and what they mean. The exit status can be one of these values: