Hitachi

JP1 Version 11 JP1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide 


9.3.23 set command (sets shell options, creates an array, or displays variable values)

Syntax

set  [-a|+a] [-f|+f] [-u|+u] [-v|+v] [-x|+x]
     [{-o|+o} [opt]]...
     [{-A|+A} name] [--] [val ...]
     [{-D|+D} name][--][{ val ... } ...]

Description

The command sets specified shell options, creates an array, or displays variable values.

This command specifies shell options and creation of arrays at the same time. If you specify setting of Shell option and creation of array at the same time, specify in the order of Shell option and creation of array. If you specify creation of array first, contents subsequent to -A option and -D option are interpreted as name and val.

Arguments

You can specify more than one option at the same time. If the same option is specified more than once, the last specification takes effect.

If no options are specified, all variables that have been assigned are output to the standard output in the format variable-name=value.

-a|+a
  • -a: Enables the allexport option.

  • +a: Disables the allexport option.

-f|+f
  • -f: Enables the noglob option.

  • +f: Disables the noglob option.

-u|+u
  • -u: Enables the nounset option.

  • +u: Disables the nounset option.

-v|+v
  • -v: Enables the verbose option. When the verbose option is enabled, all lines that are read as input to the shell are output to the standard output. All input lines are output, regardless of category, such as control statement or command. The items that are output include even the following:

    [Figure] Comments

    [Figure] Nonexistent commands

    [Figure] Commands that are not executed because they do not satisfy the conditions in an if, case, or similar statement

    [Figure] Commands that are not executed because the loop in a while statement, for statement, or other looping structure is never entered

    [Figure] Job steps that are skipped by means of the run attribute

  • +v: Disables the verbose option.

-x|+x
  • -x: Enables the xtrace option.

  • +x: Disables the xtrace option.

-o|+o
  • -o: Enables the shell option specified in opt. In addition, displays a list of the shell options that are currently set.

  • +o: Disables the shell option specified in opt. In addition, displays the shell options that are currently set, in a format that can be entered into the command line.

opt

Specifies the name of a shell option that is to be set. For details about the shell option names that can be specified, see 5.6 Shell options.

-A|+A

This command is specified if a value is substituted in one-dimensional array.

If you execute the command with the -A option specified and the array or variable specified in name already exists, the command deletes the contents of name and then creates the array or variable by assigning to it the values specified in val. The command creates as many array elements as there are arguments specified in val.

If you execute the command with the -A option specified and the array or variable specified in name already exists, the command assigns the values specified in val to the array or variable specified in name without deleting the contents of name. If the number of element values to be assigned is fewer than the number of elements existing in the array, the values of the array elements to which no value is assigned remain unchanged. If the array or variable specified in name does not exist, the command processing is the same as when the -A option is specified.

The number of array elements must be within the rage of 2 to 65,536. If only one value is specified, the command creates a variable rather than an array. Multiple arrays cannot be created simultaneously.

-D|+D

This command is specified if a value is substituted in two-dimensional array.

If the array and variable specified for name already exist when you specify and execute the -D option, delete contents of name and then create the array by substituting the value specified for val into the array and variable specified for name. Create the elements of an array for the number of variables specified for val.

If the array and variable specified for name already exist when you specify and execute the +D option, the value specified for val is substituted into the array and variable specified for name without deleting contents of name. If the number of elements to be substituted is less than the number of elements of array, the value of the element of array that is not substituted does not change. If the array and variable specified for name do not exist, behavior becomes the same as that when the -D option is specified.

If the number of elements of array that can be created is 65,536 x 64, variable is created instead of array. In addition, multiple arrays cannot be created at the same time.

name

Specify the name to be assigned to the array that is being created. If you specify a read-only variable, the command terminates with an error.

--

Specifies the end of the option specifications. Any options specified after this option are interpreted as part of val.

val

This command specifies a value to be substituted in one-dimensional array. If you specify and execute val, the value specified for val is substituted into the positional parameter. If multiple val are specified, values are substituted from the left in the order of $1, $2...

To specify the value to be substituted into an element of two-dimensional array, specify the value by enclosing with {}. One or more space character needs to be inserted between parenthesis and val.

Return codes

Return code

Meaning

0

Normal termination

1

Error termination

Notes

Example