declare, local, typeset: add pages (#7529)

This commit is contained in:
Emily Grace Seville
2021-12-19 05:46:09 +10:00
committed by GitHub
parent 0ad3a36142
commit dea25fb85a
3 changed files with 80 additions and 0 deletions

28
pages/common/declare.md Normal file
View 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}}"`