Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commit40f158b5e653503bdc9ba8d2d1bb4c355545e583 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-02-26 20:42:58 +0200
Committer
 Syndamia <kamen@syndamia.com>
2023-02-26 20:42:58 +0200
Files20ea5088f20bd11b5dfeebd872b52b2f7c5f6b83 /src
syndamia.com-40f158b5e653503bdc9ba8d2d1bb4c355545e583.tar
syndamia.com-40f158b5e653503bdc9ba8d2d1bb4c355545e583.tar.gz
syndamia.com-40f158b5e653503bdc9ba8d2d1bb4c355545e583.zip
Parent80d2ff6ad5047e01388a451d0ce3fbe104195b65 (diff)
[talks/lbs] Added compound commands section to shell slides
1 files changed, 40 insertions, 3 deletions
-rw-r--r--src/talks/linuxgraphy-by-strabo/index.md43
diff --git a/src/talks/linuxgraphy-by-strabo/index.md b/src/talks/linuxgraphy-by-strabo/index.md
index 10b2aea..7342ebf 100644
--- a/src/talks/linuxgraphy-by-strabo/index.md
+++ b/src/talks/linuxgraphy-by-strabo/index.md
@@ -894,7 +894,19 @@ Most modern shells support a lot of the more defying features of the [Bourne She
+ `#`: Everything between a # and the end of the line denotes a comment
+ `#!`: If on the first line of the file, is treated as a [shebang](https://en.wikipedia.org/wiki/Shebang_%28Unix%29), which specifies what interpreter to be used for the script
-- compound commands: Shells also often offer more advanced structured, with which to more easily write complex expressions
+- compound commands: Structures for flow control
+ In all examples, `test-command` is any command (or combination with control operators), and logic is based on exit code.
+
+ + conditional
+
+ ```
+ if test-command ; then commands-if-true
+ elif test-command ; then commands-if-true
+ else commands-if-true
+ fi
+ ```
+
+ elif statements can appear multiple times, both elif and else are optional
&&/slide
@@ -902,9 +914,34 @@ Most modern shells support a lot of the more defying features of the [Bourne She
&&slide
-## 3.2. Files and directories
+- &emsp;
+ &&lineb1
-&&lineb1
+ ```
+ case word in (pattern | ...) commands-if-true ;; ... esac
+ ```
+
+ Where the beginning brace can be ommited.
+ Patterns are according to [bash's pattern matching](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Pattern-Matching)
+
+ + loops
+
+ ```
+ while test-command; do commands-if-true; done
+ ```
+
+ ```
+ for name in words...; do commands-if-true; done
+ ```
+ If `in words...` is ommited, positional arguments are used
+
+&&/slide
+
+
+
+&&slide
+
+## 3.2. Files and directories
- `/bin`: main command programs (binaries), used by users
- `/etc`: system configuration files