mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-09-10 17:13:50 +02:00
declare, local, typeset: add pages (#7529)
This commit is contained in:
parent
0ad3a36142
commit
dea25fb85a
3 changed files with 80 additions and 0 deletions
28
pages/common/declare.md
Normal file
28
pages/common/declare.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# declare
|
||||
|
||||
> Declare variables and give them attributes.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins>.
|
||||
|
||||
- Declare a string variable with the specified value:
|
||||
|
||||
`declare {{variable}}="{{value}}"`
|
||||
|
||||
- Declare an integer variable with the specified value:
|
||||
|
||||
`declare -i {{variable}}="{{value}}"`
|
||||
|
||||
- Declare an array variable with the specified value:
|
||||
|
||||
`declare {{variable}}=({{item_a item_b item_c}})`
|
||||
|
||||
- Declare an associative array variable with the specified value:
|
||||
|
||||
`declare -A {{variable}}=({{[key_a]=item_a [key_b]=item_b [key_c]=item_c}})`
|
||||
|
||||
- Declare a readonly string variable with the specified value:
|
||||
|
||||
`declare -r {{variable}}="{{value}}"`
|
||||
|
||||
- Declare a global variable within a function with the specified value:
|
||||
|
||||
`declare -g {{variable}}="{{value}}"`
|
24
pages/common/local.md
Normal file
24
pages/common/local.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# local
|
||||
|
||||
> Declare local variables and give them attributes.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins>.
|
||||
|
||||
- Declare a string variable with the specified value:
|
||||
|
||||
`local {{variable}}="{{value}}"`
|
||||
|
||||
- Declare an integer variable with the specified value:
|
||||
|
||||
`local -i {{variable}}="{{value}}"`
|
||||
|
||||
- Declare an array variable with the specified value:
|
||||
|
||||
`local {{variable}}=({{item_a item_b item_c}})`
|
||||
|
||||
- Declare an associative array variable with the specified value:
|
||||
|
||||
`local -A {{variable}}=({{[key_a]=item_a [key_b]=item_b [key_c]=item_c}})`
|
||||
|
||||
- Declare a readonly variable with the specified value:
|
||||
|
||||
`local -r {{variable}}="{{value}}"`
|
28
pages/common/typeset.md
Normal file
28
pages/common/typeset.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
# typeset
|
||||
|
||||
> Declare variables and give them attributes.
|
||||
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Bash-Builtins>.
|
||||
|
||||
- Declare a string variable with the specified value:
|
||||
|
||||
`typeset {{variable}}="{{value}}"`
|
||||
|
||||
- Declare an integer variable with the specified value:
|
||||
|
||||
`typeset -i {{variable}}="{{value}}"`
|
||||
|
||||
- Declare an array variable with the specified value:
|
||||
|
||||
`typeset {{variable}}=({{item_a item_b item_c}})`
|
||||
|
||||
- Declare an associative array variable with the specified value:
|
||||
|
||||
`typeset -A {{variable}}=({{[key_a]=item_a [key_b]=item_b [key_c]=item_c}})`
|
||||
|
||||
- Declare a readonly variable with the specified value:
|
||||
|
||||
`typeset -r {{variable}}="{{value}}"`
|
||||
|
||||
- Declare a global variable within a function with the specified value:
|
||||
|
||||
`typeset -g {{variable}}="{{value}}"`
|
Loading…
Add table
Reference in a new issue