Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
Date: Fri, 27 May 2022 09:02:54
Message-Id: 1653642094.3690be148e96c428e51ff9f21b7572e100772e5f.ulm@gentoo
1 commit: 3690be148e96c428e51ff9f21b7572e100772e5f
2 Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 20 09:23:16 2022 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Fri May 27 09:01:34 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=3690be14
7
8 tools-reference/bash: Drop redundant quotation marks in [[ ]] tests
9
10 Remove a note that was recommending them. Use {} braces around
11 variable names throughout.
12
13 Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
14
15 tools-reference/bash/text.xml | 24 +++++++++---------------
16 1 file changed, 9 insertions(+), 15 deletions(-)
17
18 diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
19 index 821d385..d00a65c 100644
20 --- a/tools-reference/bash/text.xml
21 +++ b/tools-reference/bash/text.xml
22 @@ -91,19 +91,19 @@ To do comparisons or file attribute tests, <c>[[ ]]</c> (preferred) or
23 </p>
24
25 <codesample lang="ebuild">
26 -# is $foo zero length?
27 -if [[ -z "${foo}" ]] ; then
28 +# is ${foo} zero length?
29 +if [[ -z ${foo} ]] ; then
30 die "Please set foo"
31 fi
32
33 -# is $foo equal to "moo"?
34 -if [[ "${foo}" == "moo" ]] ; then
35 +# is ${foo} equal to "moo"?
36 +if [[ ${foo} == "moo" ]] ; then
37 einfo "Hello Larry"
38 fi
39
40 -# does "${ROOT}/etc/deleteme" exist?
41 -if [[ -f "${ROOT}/etc/deleteme" ]] ; then
42 - einfo "Please delete ${ROOT}/etc/readme manually!"
43 +# does ${ROOT}/etc/deleteme exist?
44 +if [[ -f ${ROOT}/etc/deleteme ]] ; then
45 + einfo "Please delete ${ROOT}/etc/deleteme manually!"
46 fi
47 </codesample>
48
49 @@ -134,9 +134,9 @@ syntax is possible with the former. For a simple illustration, consider:
50 </p>
51
52 <codesample lang="ebuild">
53 -bash$ [ -n $foo ] &amp;&amp; [ -z $foo ] &amp;&amp; echo "huh?"
54 +bash$ [ -n ${foo} ] &amp;&amp; [ -z ${foo} ] &amp;&amp; echo "huh?"
55 huh?
56 -bash$ [[ -n $foo ]] &amp;&amp; [[ -z $foo ]] &amp;&amp; echo "huh?"
57 +bash$ [[ -n ${foo} ]] &amp;&amp; [[ -z ${foo} ]] &amp;&amp; echo "huh?"
58 bash$
59 </codesample>
60
61 @@ -242,12 +242,6 @@ available:
62 </tr>
63 </table>
64
65 -<note>
66 -To check whether a variable is set and not blank, use <c>-n "${BLAH}"</c>
67 -rather than <c>-n $BLAH</c>. The latter will cause problems in some situations if
68 -the variable is unset.
69 -</note>
70 -
71 </body>
72 </subsection>