From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
Date: Fri, 27 May 2022 09:02:50 +0000 (UTC) [thread overview]
Message-ID: <1653642094.3690be148e96c428e51ff9f21b7572e100772e5f.ulm@gentoo> (raw)
commit: 3690be148e96c428e51ff9f21b7572e100772e5f
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 09:23:16 2022 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri May 27 09:01:34 2022 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=3690be14
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 <AT> gentoo.org>
tools-reference/bash/text.xml | 24 +++++++++---------------
1 file 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 ] && [ -z $foo ] && echo "huh?"
+bash$ [ -n ${foo} ] && [ -z ${foo} ] && echo "huh?"
huh?
-bash$ [[ -n $foo ]] && [[ -z $foo ]] && echo "huh?"
+bash$ [[ -n ${foo} ]] && [[ -z ${foo} ]] && 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>
next reply other threads:[~2022-05-27 9:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 9:02 Ulrich Müller [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-06-10 17:15 [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/ Ulrich Müller
2022-05-27 9:02 Ulrich Müller
2022-05-27 9:02 Ulrich Müller
2022-05-27 9:02 Ulrich Müller
2022-05-27 9:02 Ulrich Müller
2021-03-21 5:48 Ulrich Müller
2021-03-12 22:03 Ulrich Müller
2021-03-12 22:03 Ulrich Müller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1653642094.3690be148e96c428e51ff9f21b7572e100772e5f.ulm@gentoo \
--to=ulm@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox