aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2022-05-20 11:23:16 +0200
committerUlrich Müller <ulm@gentoo.org>2022-05-27 11:01:34 +0200
commit3690be148e96c428e51ff9f21b7572e100772e5f (patch)
treec889bf0a1830c926171367377f4db8ab47d5676d /tools-reference
parentgeneral-concepts/dependencies: Whitespace (diff)
downloaddevmanual-3690be148e96c428e51ff9f21b7572e100772e5f.tar.gz
devmanual-3690be148e96c428e51ff9f21b7572e100772e5f.tar.bz2
devmanual-3690be148e96c428e51ff9f21b7572e100772e5f.zip
tools-reference/bash: Drop redundant quotation marks in [[ ]] tests
Remove a note that was recommending them. Use {} braces around variable names throughout. Signed-off-by: Ulrich Müller <ulm@gentoo.org>
Diffstat (limited to 'tools-reference')
-rw-r--r--tools-reference/bash/text.xml24
1 files changed, 9 insertions, 15 deletions
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index 821d385..d00a65c 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -91,19 +91,19 @@ To do comparisons or file attribute tests, <c>[[ ]]</c> (preferred) or
</p>
<codesample lang="ebuild">
-# is $foo zero length?
-if [[ -z "${foo}" ]] ; then
+# is ${foo} zero length?
+if [[ -z ${foo} ]] ; then
die "Please set foo"
fi
-# is $foo equal to "moo"?
-if [[ "${foo}" == "moo" ]] ; then
+# is ${foo} equal to "moo"?
+if [[ ${foo} == "moo" ]] ; then
einfo "Hello Larry"
fi
-# does "${ROOT}/etc/deleteme" exist?
-if [[ -f "${ROOT}/etc/deleteme" ]] ; then
- einfo "Please delete ${ROOT}/etc/readme manually!"
+# does ${ROOT}/etc/deleteme exist?
+if [[ -f ${ROOT}/etc/deleteme ]] ; then
+ einfo "Please delete ${ROOT}/etc/deleteme manually!"
fi
</codesample>
@@ -134,9 +134,9 @@ syntax is possible with the former. For a simple illustration, consider:
</p>
<codesample lang="ebuild">
-bash$ [ -n $foo ] &amp;&amp; [ -z $foo ] &amp;&amp; echo "huh?"
+bash$ [ -n ${foo} ] &amp;&amp; [ -z ${foo} ] &amp;&amp; echo "huh?"
huh?
-bash$ [[ -n $foo ]] &amp;&amp; [[ -z $foo ]] &amp;&amp; echo "huh?"
+bash$ [[ -n ${foo} ]] &amp;&amp; [[ -z ${foo} ]] &amp;&amp; echo "huh?"
bash$
</codesample>
@@ -242,12 +242,6 @@ available:
</tr>
</table>
-<note>
-To check whether a variable is set and not blank, use <c>-n "${BLAH}"</c>
-rather than <c>-n $BLAH</c>. The latter will cause problems in some situations if
-the variable is unset.
-</note>
-
</body>
</subsection>