You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/commands/builtin/declare.md
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,28 +37,28 @@ Below, `[-+]X` indicates an attribute, use `-X` to set the attribute,
37
37
38
38
`[-+]A` make NAMEs associative arrays
39
39
40
-
`[-+]c`**Undocumented** convert NAMEs to \"capcase\" on assignment (makes the first letter upper-case and the rest lower). Requires Bash built with `-DCASEMOD_CAPCASE`
40
+
`[-+]c`**Undocumented** convert NAMEs to "capcase" on assignment (makes the first letter upper-case and the rest lower). Requires Bash built with `-DCASEMOD_CAPCASE`
41
41
42
42
`-f` restrict action or display to function names and definitions (removing with `+f` is valid syntax, but leads to an error message)
43
43
44
44
`-F` restrict display to function names only (plus line number and source file when debugging)
45
45
46
46
`-g` create global variables when used in a shell function; otherwise ignored (by default, `declare` declares local scope variables when used in shell functions)
47
47
48
-
`[-+]i` make NAMEs have the \"integer\" attribute
48
+
`[-+]i` make NAMEs have the "integer" attribute
49
49
50
50
`[-+]l` convert NAMEs to lower case on assignment (makes sure the variable contains only lower case letters)
51
51
52
-
`[-+]n` make NAME a reference to the variable named by its value. Introduced in Bash 4.3-alpha.\
53
-
\'\'\${!NAME}\'\' reveals the reference variable name, VALUE.\
54
-
Use `unset -n NAME` to unset the variable. (`unset -v NAME` unsets the VALUE variable.)\
52
+
`[-+]n` make NAME a reference to the variable named by its value. Introduced in Bash 4.3-alpha.
53
+
''`${!NAME}`'' reveals the reference variable name, VALUE.
54
+
Use `unset -n NAME` to unset the variable. (`unset -v NAME` unsets the VALUE variable.)
55
55
Use `[[ -R NAME ]]` to test if NAME has been set to a VALUE, another variable's name.
56
56
57
57
`-p` display the attributes and value of each NAME
58
58
59
59
`[-+]r` make NAMEs readonly (removing with `+r` is valid syntax, but not possible)
60
60
61
-
`[-+]t` make NAMEs have the \"trace\" attribute (effective only for functions)
61
+
`[-+]t` make NAMEs have the "trace" attribute (effective only for functions)
62
62
63
63
`[-+]u` convert NAMEs to upper case on assignment (makes sure the variable contains only upper case letters)
64
64
@@ -76,13 +76,13 @@ Below, `[-+]X` indicates an attribute, use `-X` to set the attribute,
76
76
!= 0 assignment to a readonly variable
77
77
!= 0 removing the readonly-attribute from a readonly variable
78
78
!= 0 assignment to an array variable without the compound assignment syntax (`array=(...)`)
79
-
!= 0 attempt to use `+a` to \"destroy\" an array
79
+
!= 0 attempt to use `+a` to "destroy" an array
80
80
!= 0 attemt to display a non-existent function with `-f`
81
81
82
82
## Notes
83
83
84
84
Unix shells offer very few datatypes. Bash and some other shells extend
85
-
this by allowing \"attributes\" to be set on variable names. The only
85
+
this by allowing "attributes" to be set on variable names. The only
86
86
attributes specified by POSIX are `export` and `readonly`, which are set
87
87
by their own dedicated builtins. Datatypes in bash have a few other
88
88
interesting capabilities such as the ability to modify data on
@@ -92,23 +92,23 @@ assignment.
92
92
93
93
### Display defined functions
94
94
95
-
`declare -f` can be used to display all defined functions\...
95
+
`declare -f` can be used to display all defined functions...
96
96
97
97
$ declare -f
98
-
foo ()
99
-
{
98
+
foo ()
99
+
{
100
100
echo "FOO is BAR"
101
101
}
102
-
world ()
103
-
{
102
+
world ()
103
+
{
104
104
echo "Hello World!"
105
105
}
106
106
107
-
\...or just a specific defined function.
107
+
...or just a specific defined function.
108
108
109
109
$ declare -f foo
110
-
foo ()
111
-
{
110
+
foo ()
111
+
{
112
112
echo "FOO is BAR"
113
113
}
114
114
@@ -172,7 +172,7 @@ for details. ksh93 namerefs are much more powerful than Bash's.
172
172
considers `typeset` a special builtin, while Bash does not - even in
173
173
POSIX mode. If you use `typeset`, you should attempt to only use it
Copy file name to clipboardExpand all lines: docs/commands/builtin/eval.md
+4-9Lines changed: 4 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ This code defines a set of identical functions using the supplied names.
55
55
### Using printf %q
56
56
57
57
The `printf %q` format string performs shell escaping on its arguments.
58
-
This makes `printf %q` the \"anti-eval\" - with each pass of a string
58
+
This makes `printf %q` the "anti-eval" - with each pass of a string
59
59
through printf requiring another `eval` to peel off the escaping again.
60
60
61
61
while (( ++n <= 5 )) || ! evalBall="eval $evalBall"; do
@@ -112,16 +112,11 @@ controlled carefully by the caller is a good way to use it.
112
112
`setopt POSIX_BUILTINS` -- looks like a regression). This works
113
113
correctly in Bash POSIX mode, Dash, and mksh.
114
114
115
-
```{=html}
116
-
<!-- -->
117
-
```
118
115
-`eval` is another one of the few Bash builtins with keyword-like
119
116
conditional parsing of arguments that are in the form of compound
120
117
assignments.
121
118
122
-
```{=html}
123
-
<!-- -->
124
-
```
119
+
125
120
$ ( eval a=( a b\\ c d ); printf '<%s> ' "${a[@]}"; echo ) # Only works in Bash.
126
121
<a> <bc> <d>
127
122
$ ( x=a; eval "$x"=( a b\\ c d ); printf '<%s> ' "${a[@]}"; echo ) # Argument is no longer in the form of a valid assignment, therefore ordinary parsing rules apply.
@@ -168,7 +163,7 @@ identical to those of [let](../../commands/builtin/let.md).
0 commit comments