Skip to content

Commit 740fc7e

Browse files
committed
docs(styleguide): update examples of quoting
1 parent ca0fde0 commit 740fc7e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

doc/styleguide.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,24 @@ shell expansions.
141141
In the following contexts, the quoting to suppress word splitting and pathname
142142
expansions are not needed.
143143

144-
- The right-hand sides of variable assignments ... `v=$var`
145-
- The arguments of conditional commands ... `[[ $var ]]`
146-
- The argument specified to `case` statement ... `case $var in foo) ;; esac`
144+
- The right-hand sides of variable assignments ... `v=WORD` (e.g. `v=$var`)
145+
- The arguments of conditional commands ... `[[ WORD ]]` (e.g. `[[ $var ]]`)
146+
- The argument specified to `case` statement ... `case WORD in foo) ;; esac`
147+
(e.g. `case $var in foo) ;; esac`)
147148

148149
In bash-completion, we do not quote them by default. However, there are
149150
exceptions where the quoting is still needed for other reasons.
150151

151152
- When the word *directly* contains shell special characters (space, tab,
152153
newline, or a character from ``;|&()<>\\$`'"#!~{``), these characters need to
153-
be quoted. The "*directly*" means that the characters produced by the shell
154-
expansions, such as `$var`, are excluded. For example, when one wants to
155-
include a whitespace as a part of the value of the word, the right-hand side
156-
can be quoted as `v="a b"`.
154+
be quoted. The "*directly*" means that the special characters produced by
155+
shell expansions are excluded here. For example, when one wants to include a
156+
whitespace as a part of the value of the word, the right-hand side can be
157+
quoted as `v="a b"`.
157158
- An empty word (i.e., the word whose value is an empty string) is specified by
158-
`""`. The right-hand sides of assignments technically can be an empty string
159-
as `var=`, but we still use `var=""` there because `shellcheck` suggests that
160-
e.g. `var= cmd` is confusing with `var=cmd`.
159+
`""`. The right-hand side of an assignment technically can be an empty
160+
string as `var=`, but we still use `var=""` there because `shellcheck`
161+
suggests that e.g. `var= cmd` is confusing with `var=cmd`.
161162
- `$*` and `${array[*]}` need to be always quoted because they can be affected
162163
by the word splitting in bash <= 4.2 even in the above contexts.
163164
- In the following contexts, double-quoting of shell expansions is needed

0 commit comments

Comments
 (0)