9.3.1 . command (executes a shell script)
Syntax
. filename [args]
Description
This command executes a shell script in the current shell. The shell script specified in filename is executed in the shell environment. The current directory of the shell script specified in filename will be the same as the current directory of the current shell being used by the . (dot) command.
Variables and functions that are set and defined in the specified shell script can be used in the current shell environment even after the specified shell script terminates. Also, variables and functions that were set or defined before the specified shell script was started can be used in the specified shell script. However, extended script commands cannot be used in the specified shell script. If an extended script command is encountered, it will be handled as a comment. For details about the extended script commands, see 9.5 Extended script commands.
Arguments
- filename
Specifies the file name of the shell script that is to be executed in the current shell.
- args
Specifies positional parameters to be used in the specified shell script. How the value of a positional parameter is set depends on whether args was specified and whether the positional parameter is changed in the specified shell script file, as summarized in the following table:
args is specified
Positional parameter is changed in the specified shell script file
Positional parameter is not changed in the specified shell script file
Yes
The value of the positional parameter in the file will be the value specified in the args argument.
The value of the positional parameter after the file has terminated will be its value just before execution of the . (dot) command.
Same as at the left.
No
The value of the positional parameter in the file will be the value just before execution of the . (dot) command.
The value of the positional parameter after the file has terminated will be the new value acquired in the file.
The value of the positional parameter in the file will be the value just before execution of the . (dot) command.
The value of the positional parameter after the file has terminated will be its value just before execution of the . (dot) command.
Return codes
Return code |
Meaning |
---|---|
0 to 255 |
Normal termination
|
0 |
Normal termination
|
1 |
Error termination
|
Notes
The shell script specified in this command does not send output to the script image file in the spool directory. To output the execution history to the script image file, you must use the #-adsh_script command.
When this command terminates normally, its execution results are not output to the job execution log. Note also that this command does not identify whether the job or job step terminated normally or with an error. Refer instead to the execution results of the external script that was called.
If the command syntax of this special built-in command is invalid, it exits the shell that is executing the command.
Example
Execute a shell script in the current shell.
. ./test.sh