Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


: command (expands arguments)

Organization of this page

Format

: [arguments]

Description

This command expands arguments. It always returns 0 as the return code.

For example, you can omit the else or elif clause from an if statement, but not the then clause. In such a case, specify the : command for the then clause as follows, to indicate that no action is to be taken when the condition is satisfied:

if [conditional-expression]; then
  :                  # Takes no action if the result of the conditional expression is true.
else
  cmd1               # Executes command if the result of the conditional expression is false.
fi

Arguments

arguments

Specifies arguments that are to be expanded as explained below.

Job definition script specification example
set -x
NUMBER=1
: $NUMBER
Result that is output to the standard error output
+ NUMBER=1
+ : 1                  # Outputs the expansion result of the variable NUMBER.

Therefore, by specifying a variable substitution in the arguments argument, you can check whether a value is stored in the variable and substitute a value if there is no value.

Job definition script specification example
STRING01=ABC
: ${STRING01:=DEF}          # Because variable STRING01 stores ABC, no action is taken.
: ${STRING02:=GHI}          # Because variable STRING02 is undefined, CHI is substituted.
echo $STRING01 $STRING02    # "ABC GHI" is output to the standard output.

If variable substitution in the format ${variable:?word} or ${variable?word} is specified in the arguments argument and no value is stored in variable, processing terminates with an error with 1 as the return code.

Note that this command accepts no options. If an option is specified, it is ignored and processing continues.

Return codes

Return code

Meaning

0

Normal termination

1

Error termination

  • A variable substitution in the format ${variable:?word} was specified in an argument, but variable was not defined or no value was set in variable.

  • A variable substitution in the format ${variable?word} was specified in an argument, but variable was not defined.

Notes

Usage example