Linux

  1. Home
  2. Computing & Technology
  3. Linux

From Authors, for About.com

expansion is taken to be the name of the command and the rest are arguments to that command. Then redirections are performed, then strings assigned to variables are expanded. If no command name results, variables will affect the current shell environment.

An important part of the tasks of the shell is to search for commands. Bash does this as follows:

  • Check whether the command contains slashes. If not, first check with the function list to see if it contains a command by the name we are looking for.

  • If command is not a function, check for it in the built-in list.

  • If command is neither a function nor a built-in, look for it analyzing the directories listed in PATH . Bash uses a hash table (data storage area in memory) to remember the full path names of executables so extensive PATH searches can be avoided.

  • If the search is unsuccessful, bash prints an error message and returns an exit status of 127.

  • If the search was successful or if the command contains slashes, the shell executes the command in a separate execution environment.

  • If execution fails because the file is not executable and not a directory, it is assumed to be a shell script.

  • If the command was not begun asynchronously, the shell waits for the command to complete and collects its exit status.

1.4.1.8. Shell scripts

When a file containing shell commands is used as the first non-option argument when invoking Bash (without -c or -s , this will create a non-interactive shell. This shell first searches for the script file in the current directory, then looks in PATH if the file cannot be found there.


   Prev    Home    Next
   Executing commands    Up    Developing good scripts

Explore Linux

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Linux

  1. Home
  2. Computing & Technology
  3. Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.