TrumanWong

local

Define local variables within the function.

Summary

local [-aAfFgilnrtux] [-p] [name[=value] ...]

The main purpose

  • Define local variables within the function
  • Show local variables
  • Define global variables within functions

Options

The options of the local command are the same as those of the declare command. Please refer to the options of the declare command.

Parameters

name (optional): variable name or defined function name.

value (optional): The value of the variable.

return value

local returns true unless you provide an illegal option, an assignment error, or use the local command outside a function.

example

For related examples, please refer to the declare command.

Incorrect usage

  • Use this command outside a function.

Notice

  1. This command is a built-in bash command. For related help information, please check the help command and the corresponding parts of man bash and info bash.