16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2. sh performs parameter substitution, command substitution, or arithmetic<br />

substitution, as appropriate, in the order that the words appear on the command<br />

line, expanding each word to a field (see the appropriate topics).<br />

3. sh scans each field produced in step 2 for unquoted characters from the IFS<br />

environment variable and further subdivides this field into one or more new<br />

fields.<br />

4. sh expands any aliases to their definitions.<br />

5. sh performs pathname expansion on each unquoted field from step 3.<br />

6. sh removes all quote mechanisms (\, ’, and ") that were present in the original<br />

word unless they have themselves been quoted.<br />

The shell considers the first field of the expanded result to be a command.<br />

The expanded simple command can contain variable assignments and redirections.<br />

Variable assignments affect the current execution environment. After expansion, the<br />

shell handles all redirection constructs, and the command, if one was found, it<br />

performs the redirection in a child shell environment (see “Shell Execution<br />

Environments” on page 567).<br />

When a simple command contains a command name, variable assignments in the<br />

command affect only the execution of that command.<br />

After the shell has expanded all appropriate arguments in a simple command, but<br />

before it performs filename generation, it examines the command name (if the<br />

command has one). sh first checks the names against currently defined aliases<br />

(see the alias command) and functions (see function under “Reserved-Word<br />

<strong>Command</strong>s” on page 552), and finally against the set of built-in commands:<br />

commands that the shell can run directly without searching for program files. Built-in<br />

commands are described in “Built-in <strong>Command</strong>s” on page 568.<br />

The autoload command, an alias of typeset –fu, identifies functions which are not<br />

yet defined. The first time an undefined function is called within the shell, the shell<br />

will search directories in the FPATH shell variable for a file with the same name as<br />

the function. If a matching file is found, it is assumed to contain the function<br />

definition of the same name. The file is read and executed in the current shell<br />

environment, storing the function in the shell’s memory for subsequent execution.<br />

(Multiple function definitions may be contained in the same file. When the file is<br />

processed by the shell, all the functions will be defined. Every function definition in<br />

the file should be a link name to the file.)<br />

If the command is a built-in or function, the shell executes it.<br />

If the command name is not a function or a built-in command, the z/<strong>OS</strong> shell looks<br />

for a program file or script file that contains an executable version of that command.<br />

The shell uses the following procedure to locate the program file:<br />

v If the command name typed to the shell has slash (/) characters in its name, the<br />

command is taken to be a full pathname (absolute or relative). The shell tries to<br />

execute the contents of that file.<br />

v Otherwise, the shell performs a path search. To do this, the shell obtains the<br />

value of the PATH environment variable. The value should be a list of directory<br />

names. sh searches under each directory for a file, the name of which matches<br />

the command name. If the FPATH shell variable is set, the shell will search the<br />

PATH and FPATH directories. If a file with a name matching the command name<br />

is found in the same directory in both PATH and FPATH, or if a matching file is<br />

sh<br />

Chapter 2. Shell command descriptions 557

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!