* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2021-03-12 22:03 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2021-03-12 22:03 UTC (permalink / raw
To: gentoo-commits
commit: cabd2fc8b2890b60941b504e2625df931630da84
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 12 21:04:46 2021 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Mar 12 22:02:36 2021 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=cabd2fc8
tools-reference/bash: make clear that [[ ]] is preferred earlier on
Signed-off-by: Sam James <sam <AT> gentoo.org>
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index 77b5298..0583184 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -86,8 +86,8 @@ fi
<body>
<p>
-To do comparisons or file attribute tests, <c>[ ]</c> or <c>[[ ]]</c> blocks are
-needed.
+To do comparisons or file attribute tests, <c>[[ ]]</c> (preferred) or
+<c>[ ]</c> blocks are needed.
</p>
<codesample lang="ebuild">
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2021-03-12 22:03 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2021-03-12 22:03 UTC (permalink / raw
To: gentoo-commits
commit: 0f141508fdd8aef771d598357e78f9578da7325e
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 12 21:07:35 2021 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Mar 12 22:02:56 2021 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=0f141508
tools-reference/bash: fix typo
Signed-off-by: Sam James <sam <AT> gentoo.org>
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index 0583184..56608c4 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -779,7 +779,7 @@ output (<c>stdout</c>) as a string.
<note>
The <c>`command`</c> construct also does this, but should be avoided in
-favour of <c>$(command )</c> for clarity, ease of reading and nesting purposes.
+favour of <c>$(command)</c> for clarity, ease of reading and nesting purposes.
</note>
<codesample lang="ebuild">
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2021-03-21 5:48 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2021-03-21 5:48 UTC (permalink / raw
To: gentoo-commits
commit: 04d0b38c276a5eb47c7d9485a97dfd73ab5cbff4
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 12 21:06:45 2021 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Mar 21 05:47:41 2021 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=04d0b38c
tools-reference/bash: elaborate on why bash tests are preferred
Signed-off-by: Sam James <sam <AT> gentoo.org>
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index 56608c4..821d385 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -119,6 +119,14 @@ The <c>[[ ]]</c> form is generally safer than <c>[ ]</c> and should be used in
all new code.
</important>
+<p>
+POSIX compliance is not a concern for ebuilds, as their interpreter is
+guaranteed to be GNU Bash. POSIX style tests have different semantics and
+using the common forms of tests adheres to the principle of least surprise.
+Most developers will be used to Bash test semantics and behaviour and deviating
+from this in ebuilds may be confusing.
+</p>
+
<p>
This is because <c>[[ ]]</c> is a bash syntax construct, whereas <c>[ ]</c> is a
program which happens to be implemented as an internal <d/> as such, cleaner
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2022-05-27 9:02 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2022-05-27 9:02 UTC (permalink / raw
To: gentoo-commits
commit: 3a69349de3d0c6ddc7eb27afd20f3416ece67ad1
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 09:49:35 2022 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri May 27 09:01:35 2022 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=3a69349d
tools-reference/bash: More compact table formatting in source code
No change of text.
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 796 ++++++++++++++----------------------------
1 file changed, 270 insertions(+), 526 deletions(-)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index ee1d7e3..0a7c33f 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -153,54 +153,30 @@ following are available:
</p>
<table>
- <tr>
- <th>
- Operator
- </th>
- <th>
- Purpose
- </th>
- </tr>
- <tr>
- <ti>
- <c>==</c> (also <c>=</c>)
- </ti>
- <ti>
- String equality
- </ti>
- </tr>
- <tr>
- <ti>
- <c>!=</c>
- </ti>
- <ti>
- String inequality
- </ti>
- </tr>
- <tr>
- <ti>
- <c><</c>
- </ti>
- <ti>
- String lexiographic comparison (before)
- </ti>
- </tr>
- <tr>
- <ti>
- <c>></c>
- </ti>
- <ti>
- String lexiographic comparison (after)
- </ti>
- </tr>
- <tr>
- <ti>
- <c>=~</c>
- </ti>
- <ti>
- String regular expression match
- </ti>
- </tr>
+<tr>
+ <th>Operator</th>
+ <th>Purpose</th>
+</tr>
+<tr>
+ <ti><c>==</c> (also <c>=</c>)</ti>
+ <ti>String equality</ti>
+</tr>
+<tr>
+ <ti><c>!=</c></ti>
+ <ti>String inequality</ti>
+</tr>
+<tr>
+ <ti><c><</c></ti>
+ <ti>String lexiographic comparison (before)</ti>
+</tr>
+<tr>
+ <ti><c>></c></ti>
+ <ti>String lexiographic comparison (after)</ti>
+</tr>
+<tr>
+ <ti><c>=~</c></ti>
+ <ti>String regular expression match</ti>
+</tr>
</table>
</body>
@@ -216,30 +192,18 @@ available:
</p>
<table>
- <tr>
- <th>
- Operator
- </th>
- <th>
- Purpose
- </th>
- </tr>
- <tr>
- <ti>
- <c>-z "string"</c>
- </ti>
- <ti>
- String has zero length
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-n "string"</c>
- </ti>
- <ti>
- String has non-zero length
- </ti>
- </tr>
+<tr>
+ <th>Operator</th>
+ <th>Purpose</th>
+</tr>
+<tr>
+ <ti><c>-z "string"</c></ti>
+ <ti>String has zero length</ti>
+</tr>
+<tr>
+ <ti><c>-n "string"</c></ti>
+ <ti>String has non-zero length</ti>
+</tr>
</table>
</body>
@@ -255,62 +219,34 @@ following are available:
</p>
<table>
- <tr>
- <th>
- Operator
- </th>
- <th>
- Purpose
- </th>
- </tr>
- <tr>
- <ti>
- <c>-eq</c>
- </ti>
- <ti>
- Integer equality
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-ne</c>
- </ti>
- <ti>
- Integer inequality
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-lt</c>
- </ti>
- <ti>
- Integer less than
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-le</c>
- </ti>
- <ti>
- Integer less than or equal to
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-gt</c>
- </ti>
- <ti>
- Integer greater than
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-ge</c>
- </ti>
- <ti>
- Integer greater than or equal to
- </ti>
- </tr>
+<tr>
+ <th>Operator</th>
+ <th>Purpose</th>
+</tr>
+<tr>
+ <ti><c>-eq</c></ti>
+ <ti>Integer equality</ti>
+</tr>
+<tr>
+ <ti><c>-ne</c></ti>
+ <ti>Integer inequality</ti>
+</tr>
+<tr>
+ <ti><c>-lt</c></ti>
+ <ti>Integer less than</ti>
+</tr>
+<tr>
+ <ti><c>-le</c></ti>
+ <ti>Integer less than or equal to</ti>
+</tr>
+<tr>
+ <ti><c>-gt</c></ti>
+ <ti>Integer greater than</ti>
+</tr>
+<tr>
+ <ti><c>-ge</c></ti>
+ <ti>Integer greater than or equal to</ti>
+</tr>
</table>
</body>
@@ -326,182 +262,94 @@ available (lifted from <c>man bash</c>):
</p>
<table>
- <tr>
- <th>
- Operator
- </th>
- <th>
- Purpose
- </th>
- </tr>
- <tr>
- <ti>
- <c>-a file</c>
- </ti>
- <ti>
- Exists (use <c>-e</c> instead)
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-b file</c>
- </ti>
- <ti>
- Exists and is a block special file
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-c file</c>
- </ti>
- <ti>
- Exists and is a character special file
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-d file</c>
- </ti>
- <ti>
- Exists and is a directory
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-e file</c>
- </ti>
- <ti>
- Exists
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-f file</c>
- </ti>
- <ti>
- Exists and is a regular file
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-g file</c>
- </ti>
- <ti>
- Exists and is set-group-id
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-h file</c>
- </ti>
- <ti>
- Exists and is a symbolic link
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-k file</c>
- </ti>
- <ti>
- Exists and its sticky bit is set
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-p file</c>
- </ti>
- <ti>
- Exists and is a named pipe (FIFO)
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-r file</c>
- </ti>
- <ti>
- Exists and is readable
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-s file</c>
- </ti>
- <ti>
- Exists and has a size greater than zero
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-t fd</c>
- </ti>
- <ti>
- Descriptor fd is open and refers to a terminal
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-u file</c>
- </ti>
- <ti>
- Exists and its set-user-id bit is set
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-w file</c>
- </ti>
- <ti>
- Exists and is writable
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-x file</c>
- </ti>
- <ti>
- Exists and is executable
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-O file</c>
- </ti>
- <ti>
- Exists and is owned by the effective user id
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-G file</c>
- </ti>
- <ti>
- Exists and is owned by the effective group id
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-L file</c>
- </ti>
- <ti>
- Exists and is a symbolic link
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-S file</c>
- </ti>
- <ti>
- Exists and is a socket
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-N file</c>
- </ti>
- <ti>
- Exists and has been modified since it was last read
- </ti>
- </tr>
+<tr>
+ <th>Operator</th>
+ <th>Purpose</th>
+</tr>
+<tr>
+ <ti><c>-a file</c></ti>
+ <ti>Exists (use <c>-e</c> instead)</ti>
+</tr>
+<tr>
+ <ti><c>-b file</c></ti>
+ <ti>Exists and is a block special file</ti>
+</tr>
+<tr>
+ <ti><c>-c file</c></ti>
+ <ti>Exists and is a character special file</ti>
+</tr>
+<tr>
+ <ti><c>-d file</c></ti>
+ <ti>Exists and is a directory</ti>
+</tr>
+<tr>
+ <ti><c>-e file</c></ti>
+ <ti>Exists</ti>
+</tr>
+<tr>
+ <ti><c>-f file</c></ti>
+ <ti>Exists and is a regular file</ti>
+</tr>
+<tr>
+ <ti><c>-g file</c></ti>
+ <ti>Exists and is set-group-id</ti>
+</tr>
+<tr>
+ <ti><c>-h file</c></ti>
+ <ti>Exists and is a symbolic link</ti>
+</tr>
+<tr>
+ <ti><c>-k file</c></ti>
+ <ti>Exists and its sticky bit is set</ti>
+</tr>
+<tr>
+ <ti><c>-p file</c></ti>
+ <ti>Exists and is a named pipe (FIFO)</ti>
+</tr>
+<tr>
+ <ti><c>-r file</c></ti>
+ <ti>Exists and is readable</ti>
+</tr>
+<tr>
+ <ti><c>-s file</c></ti>
+ <ti>Exists and has a size greater than zero</ti>
+</tr>
+<tr>
+ <ti><c>-t fd</c></ti>
+ <ti>Descriptor fd is open and refers to a terminal</ti>
+</tr>
+<tr>
+ <ti><c>-u file</c></ti>
+ <ti>Exists and its set-user-id bit is set</ti>
+</tr>
+<tr>
+ <ti><c>-w file</c></ti>
+ <ti>Exists and is writable</ti>
+</tr>
+<tr>
+ <ti><c>-x file</c></ti>
+ <ti>Exists and is executable</ti>
+</tr>
+<tr>
+ <ti><c>-O file</c></ti>
+ <ti>Exists and is owned by the effective user id</ti>
+</tr>
+<tr>
+ <ti><c>-G file</c></ti>
+ <ti>Exists and is owned by the effective group id</ti>
+</tr>
+<tr>
+ <ti><c>-L file</c></ti>
+ <ti>Exists and is a symbolic link</ti>
+</tr>
+<tr>
+ <ti><c>-S file</c></ti>
+ <ti>Exists and is a socket</ti>
+</tr>
+<tr>
+ <ti><c>-N file</c></ti>
+ <ti>Exists and has been modified since it was last read</ti>
+</tr>
</table>
</body>
@@ -517,41 +365,25 @@ following are available (lifted from <c>man bash</c>):
</p>
<table>
- <tr>
- <th>
- Operator
- </th>
- <th>
- Purpose
- </th>
- </tr>
- <tr>
- <ti>
- <c>file1 -nt file2</c>
- </ti>
- <ti>
- file1 is newer (according to modification date) than
- file2, or if file1 exists and file2 does not.
- </ti>
- </tr>
- <tr>
- <ti>
- <c>file1 -ot file2</c>
- </ti>
- <ti>
- file1 is older than file2, or if file2 exists and
- file1 does not.
- </ti>
- </tr>
- <tr>
- <ti>
- <c>file1 -ef file2</c>
- </ti>
- <ti>
- file1 and file2 refer to the same device and inode
- numbers.
- </ti>
- </tr>
+<tr>
+ <th>Operator</th>
+ <th>Purpose</th>
+</tr>
+<tr>
+ <ti><c>file1 -nt file2</c></ti>
+ <ti>
+ file1 is newer (according to modification date) than file2,
+ or if file1 exists and file2 does not.
+ </ti>
+</tr>
+<tr>
+ <ti><c>file1 -ot file2</c></ti>
+ <ti>file1 is older than file2, or if file2 exists and file1 does not.</ti>
+</tr>
+<tr>
+ <ti><c>file1 -ef file2</c></ti>
+ <ti>file1 and file2 refer to the same device and inode numbers.</ti>
+</tr>
</table>
</body>
@@ -568,39 +400,23 @@ These are used <e>outside</e> of the <c>[[ ]]</c> blocks. For operator precedenc
</p>
<table>
- <tr>
- <th>
- Construct
- </th>
- <th>
- Effect
- </th>
- </tr>
- <tr>
- <ti>
- <c>first || second</c>
- </ti>
- <ti>
- first <e>or</e> second (short circuit)
- </ti>
- </tr>
- <tr>
- <ti>
- <c>
- first && second</c>
- </ti>
- <ti>
- first <e>and</e> second (short circuit)
- </ti>
- </tr>
- <tr>
- <ti>
- <c>! condition</c>
- </ti>
- <ti>
- <e>not</e> condition
- </ti>
- </tr>
+<tr>
+ <th>Construct</th>
+ <th>Effect</th>
+</tr>
+<tr>
+ <ti><c>first || second</c></ti>
+ <ti>first <e>or</e> second (short circuit)</ti>
+</tr>
+<tr>
+ <ti><c>
+first && second</c></ti>
+ <ti>first <e>and</e> second (short circuit)</ti>
+</tr>
+<tr>
+ <ti><c>! condition</c></ti>
+ <ti><e>not</e> condition</ti>
+</tr>
</table>
@@ -878,160 +694,88 @@ operators are supported (the table is in order of precedence, highest first):
</p>
<table>
- <tr>
- <th>
- Operators
- </th>
- <th>
- Effect
- </th>
- </tr>
- <tr>
- <ti>
- <c>var++</c>, <c>var--</c>
- </ti>
- <ti>
- Variable post-increment, post-decrement
- </ti>
- </tr>
- <tr>
- <ti>
- <c>++var</c>, <c>--var</c>
- </ti>
- <ti>
- Variable pre-increment, pre-decrement
- </ti>
- </tr>
- <tr>
- <ti>
- <c>-</c>, <c>+</c>
- </ti>
- <ti>
- Unary minus and plus
- </ti>
- </tr>
- <tr>
- <ti>
- <c>!</c>, <c>~</c>
- </ti>
- <ti>
- Logical negation, bitwise negation
- </ti>
- </tr>
- <tr>
- <ti>
- <c>**</c>
- </ti>
- <ti>
- Exponentiation
- </ti>
- </tr>
- <tr>
- <ti>
- <c>*</c>, <c>/</c>, <c>%</c>
- </ti>
- <ti>
- Multiplication, division, remainder
- </ti>
- </tr>
- <tr>
- <ti>
- <c>+</c>, <c>-</c>
- </ti>
- <ti>
- Addition, subtraction
- </ti>
- </tr>
- <tr>
- <ti>
- <c><<</c>, <c>>></c>
- </ti>
- <ti>
- Left, right bitwise shifts
- </ti>
- </tr>
- <tr>
- <ti>
- <c><=</c>, <c>>=</c>, <c><</c>, <c>></c>
- </ti>
- <ti>
- Comparison: less than or equal to, greater than or
- equal to, strictly less than, strictly greater than
- </ti>
- </tr>
- <tr>
- <ti>
- <c>==</c>, <c>!=</c>
- </ti>
- <ti>
- Equality, inequality
- </ti>
- </tr>
- <tr>
- <ti>
- <c>&</c>
- </ti>
- <ti>
- Bitwise AND
- </ti>
- </tr>
- <tr>
- <ti>
- <c>^</c>
- </ti>
- <ti>
- Bitwise exclusive OR
- </ti>
- </tr>
- <tr>
- <ti>
- <c>|</c>
- </ti>
- <ti>
- Bitwise OR
- </ti>
- </tr>
- <tr>
- <ti>
- <c>&&</c>
- </ti>
- <ti>
- Logical AND
- </ti>
- </tr>
- <tr>
- <ti>
- <c>||</c>
- </ti>
- <ti>
- Logical OR
- </ti>
- </tr>
- <tr>
- <ti>
- <c>expr ? expr : expr</c>
- </ti>
- <ti>
- Conditional operator
- </ti>
- </tr>
- <tr>
- <ti>
- <c>=</c>, <c>*=</c>, <c>/=</c>, <c>%=</c>, <c>+=</c>, <c>-=</c>, <c><<=</c>,
- <c>>>=</c>, <c>&=</c>, <c>^=</c>, <c>|=</c>
- </ti>
- <ti>
- Assignment
- </ti>
- </tr>
- <tr>
- <ti>
- <c>expr1 , expr2</c>
- </ti>
- <ti>
- Multiple statements
- </ti>
- </tr>
+<tr>
+ <th>Operators</th>
+ <th>Effect</th>
+</tr>
+<tr>
+ <ti><c>var++</c>, <c>var--</c></ti>
+ <ti>Variable post-increment, post-decrement</ti>
+</tr>
+<tr>
+ <ti><c>++var</c>, <c>--var</c></ti>
+ <ti>Variable pre-increment, pre-decrement</ti>
+</tr>
+<tr>
+ <ti><c>-</c>, <c>+</c></ti>
+ <ti>Unary minus and plus</ti>
+</tr>
+<tr>
+ <ti><c>!</c>, <c>~</c></ti>
+ <ti>Logical negation, bitwise negation</ti>
+</tr>
+<tr>
+ <ti><c>**</c></ti>
+ <ti>Exponentiation</ti>
+</tr>
+<tr>
+ <ti><c>*</c>, <c>/</c>, <c>%</c></ti>
+ <ti>Multiplication, division, remainder</ti>
+</tr>
+<tr>
+ <ti><c>+</c>, <c>-</c></ti>
+ <ti>Addition, subtraction</ti>
+</tr>
+<tr>
+ <ti><c><<</c>, <c>>></c></ti>
+ <ti>Left, right bitwise shifts</ti>
+</tr>
+<tr>
+ <ti><c><=</c>, <c>>=</c>, <c><</c>, <c>></c></ti>
+ <ti>
+ Comparison: less than or equal to, greater than or equal to,
+ strictly less than, strictly greater than
+ </ti>
+</tr>
+<tr>
+ <ti><c>==</c>, <c>!=</c></ti>
+ <ti>Equality, inequality</ti>
+</tr>
+<tr>
+ <ti><c>&</c></ti>
+ <ti>Bitwise AND</ti>
+</tr>
+<tr>
+ <ti><c>^</c></ti>
+ <ti>Bitwise exclusive OR</ti>
+</tr>
+<tr>
+ <ti><c>|</c></ti>
+ <ti>Bitwise OR</ti>
+</tr>
+<tr>
+ <ti><c>&&</c></ti>
+ <ti>Logical AND</ti>
+</tr>
+<tr>
+ <ti><c>||</c></ti>
+ <ti>Logical OR</ti>
+</tr>
+<tr>
+ <ti><c>expr ? expr : expr</c></ti>
+ <ti>Conditional operator</ti>
+</tr>
+<tr>
+ <ti>
+ <c>=</c>, <c>*=</c>, <c>/=</c>, <c>%=</c>, <c>+=</c>, <c>-=</c>,
+ <c><<=</c>, <c>>>=</c>, <c>&=</c>, <c>^=</c>, <c>|=</c>
+ </ti>
+ <ti>Assignment</ti>
+</tr>
+<tr>
+ <ti><c>expr1 , expr2</c></ti>
+ <ti>Multiple statements</ti>
+</tr>
</table>
<note>
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2022-05-27 9:02 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2022-05-27 9:02 UTC (permalink / raw
To: gentoo-commits
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>
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2022-05-27 9:02 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2022-05-27 9:02 UTC (permalink / raw
To: gentoo-commits
commit: 14af4234f132fdcc2e5d2c94416b3035bbd12670
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 09:25:23 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=14af4234
tools-reference/bash: Remove obsolete comment about Bash 3
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index d00a65c..ee1d7e3 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -198,7 +198,7 @@ following are available:
<c>=~</c>
</ti>
<ti>
- String regular expression match (<b>bash 3 only</b>, not currently allowed in ebuilds)
+ String regular expression match
</ti>
</tr>
</table>
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2022-05-27 9:02 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2022-05-27 9:02 UTC (permalink / raw
To: gentoo-commits
commit: 512c283a0345ed0c4c72f08a3d60f024d704873c
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat May 21 08:14:11 2022 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri May 27 09:01:36 2022 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=512c283a
tools-reference/bash: Rework table on file comparison
- Replace "same device and inode numbers" by "hard link".
- Fix grammar (remove "if").
- Remove full stops (according to style guide).
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index cb5522a..092e95d 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -360,8 +360,8 @@ available (lifted from <c>man bash</c>):
<body>
<p>
-The general form of a file comparison is <c>"file1" -operator "file2"</c>. The
-following are available (lifted from <c>man bash</c>):
+The general form of a file comparison is <c>"file1" -operator "file2"</c>.
+The following are available:
</p>
<table>
@@ -373,16 +373,16 @@ following are available (lifted from <c>man bash</c>):
<ti><c>file1 -nt file2</c></ti>
<ti>
file1 is newer (according to modification date) than file2,
- or if file1 exists and file2 does not.
+ or file1 exists and file2 does not
</ti>
</tr>
<tr>
<ti><c>file1 -ot file2</c></ti>
- <ti>file1 is older than file2, or if file2 exists and file1 does not.</ti>
+ <ti>file1 is older than file2, or file2 exists and file1 does not</ti>
</tr>
<tr>
<ti><c>file1 -ef file2</c></ti>
- <ti>file1 and file2 refer to the same device and inode numbers.</ti>
+ <ti>file1 is a hard link to file2</ti>
</tr>
</table>
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2022-05-27 9:02 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2022-05-27 9:02 UTC (permalink / raw
To: gentoo-commits
commit: e86df6843bedc2c51b2bb0947e45b802ede88033
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 09:54:57 2022 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri May 27 09:01:35 2022 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=e86df684
tools-reference/bash: Fix a typo
lexiographic -> lexicographic
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index 0a7c33f..cb5522a 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -167,11 +167,11 @@ following are available:
</tr>
<tr>
<ti><c><</c></ti>
- <ti>String lexiographic comparison (before)</ti>
+ <ti>String lexicographic comparison (before)</ti>
</tr>
<tr>
<ti><c>></c></ti>
- <ti>String lexiographic comparison (after)</ti>
+ <ti>String lexicographic comparison (after)</ti>
</tr>
<tr>
<ti><c>=~</c></ti>
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/
@ 2022-06-10 17:15 Ulrich Müller
0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Müller @ 2022-06-10 17:15 UTC (permalink / raw
To: gentoo-commits
commit: 7d05c22848ed37bf5b594a30e56ee2793d1b1afb
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 4 21:24:47 2022 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Jun 10 17:14:07 2022 +0000
URL: https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=7d05c228
tools-reference/bash: Add tables of metacharacters and constructs
Parts of this have been taken from the Bash Reference Manual authored by
Chet Ramey and Brian Fox. See https://bugs.gentoo.org/829916#c9.
Closes: https://bugs.gentoo.org/829916
Reported-by: Alexis <flexibeast <AT> gmail.com>
Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>
tools-reference/bash/text.xml | 61 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 54 insertions(+), 7 deletions(-)
diff --git a/tools-reference/bash/text.xml b/tools-reference/bash/text.xml
index 092e95d..5e541ca 100644
--- a/tools-reference/bash/text.xml
+++ b/tools-reference/bash/text.xml
@@ -667,18 +667,65 @@ The <c>pattern</c> may contain a number of special metacharacters for pattern
matching.
</p>
-<todo>
-tables of bash metachars
-</todo>
+<table>
+<tr>
+ <th>Character</th>
+ <th>Meaning</th>
+</tr>
+<tr>
+ <ti><c>*</c></ti>
+ <ti>Matches any string, including the null string</ti>
+</tr>
+<tr>
+ <ti><c>?</c></ti>
+ <ti>Matches any single character</ti>
+</tr>
+<tr>
+ <ti><c>[...]</c></ti>
+ <ti>Matches any one of the enclosed characters</ti>
+</tr>
+</table>
+
+<p>
+Refer to the
+<uri link="https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html">
+Bash Reference Manual</uri> for further details and caveats regarding these
+characters.
+</p>
<p>
If the <c>extglob</c> shell option is enabled, a number of additional constructs
-are available. These can be <e>extremely</e> useful sometimes.
+are available. These can be <e>extremely</e> useful sometimes. In the following
+table, a <c>pattern-list</c> is a list of one or more patterns separated by
+<c>|</c>.
</p>
-<todo>
-table of extra bash goodies
-</todo>
+<table>
+<tr>
+ <th>Construct</th>
+ <th>Meaning</th>
+</tr>
+<tr>
+ <ti><c>?(pattern-list)</c></ti>
+ <ti>Matches zero or one occurrence of the given patterns</ti>
+</tr>
+<tr>
+ <ti><c>*(pattern-list)</c></ti>
+ <ti>Matches zero or more occurrences of the given patterns</ti>
+</tr>
+<tr>
+ <ti><c>+(pattern-list)</c></ti>
+ <ti>Matches one or more occurrences of the given patterns</ti>
+</tr>
+<tr>
+ <ti><c>@(pattern-list)</c></ti>
+ <ti>Matches one of the given patterns</ti>
+</tr>
+<tr>
+ <ti><c>!(pattern-list)</c></ti>
+ <ti>Matches anything except one of the given patterns</ti>
+</tr>
+</table>
</body>
</subsection>
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-06-10 17:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-27 9:02 [gentoo-commits] proj/devmanual:master commit in: tools-reference/bash/ Ulrich Müller
-- strict thread matches above, loose matches on Subject: below --
2022-06-10 17:15 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox