summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/bash-style.cli33
1 files changed, 32 insertions, 1 deletions
diff --git a/doc/bash-style.cli b/doc/bash-style.cli
index 93cf9e0..f81479b 100644
--- a/doc/bash-style.cli
+++ b/doc/bash-style.cli
@@ -54,7 +54,8 @@ done
\
For \c{if} use \c{[ ]} for basic tests and \c{[[ ]]} only if the previous form
-is not sufficient. Never use \c{test}. Do use \c{elif}.
+is not sufficient. Use \c{test} for filesystem tests (presence of files,
+etc). Do use \c{elif}.
\h1#struct|Structure|
@@ -282,12 +283,42 @@ if ! grep \"foo\" /tmp/bar; then
fi
\
+Note that the \c{if}-condition can be combined with capturing the output, for
+example:
+
+\
+if v=\"$(...)\"; then
+ ...
+fi
+\
+
If you need to ignore the exit status, you can use \c{|| true}, for example:
\
foo || true
\
+
+\h1#bool|Boolean|
+
+For boolean values use empty for false and \c{true} for true. This way you
+can have terse and natural looking conditions, for example:
+
+\
+first=true
+while ...; do
+
+ if [ ! \"$first\" ]; then
+ ...
+ fi
+
+ if [ \"$first\" ]; then
+ first=
+ fi
+
+done
+\
+
\h1#function|Functions|
If a function takes arguments, provide a brief usage after the function