aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-01-25 08:32:42 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-01-25 08:32:42 +0100
commitf7fb4c7303a5776ddb421d182a92f679a8b0f868 (patch)
tree39e6cc4c2fa9117b1ba78964de0b6786fb572c38 /src/tools
parent8c9fd06e839c06717dd2dcb067371a5e1fc71801 (diff)
downloadnotes-f7fb4c7303a5776ddb421d182a92f679a8b0f868.tar.gz
notes-f7fb4c7303a5776ddb421d182a92f679a8b0f868.zip
bash/zsh/fish: add process substitution
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/bash.md9
-rw-r--r--src/tools/fish.md6
-rw-r--r--src/tools/zsh.md12
3 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/bash.md b/src/tools/bash.md
index 9150963..a2b7944 100644
--- a/src/tools/bash.md
+++ b/src/tools/bash.md
@@ -104,6 +104,14 @@ command 2>&1 >file
1. duplicate `fd 1` to `fd 2`, effectively redirecting `stderr` to `stdout`
2. redirect `stdout` to `file`
+## Process substitution ([ref][psub])
+
+Process substitution allows to redirect the stdout of multiple processes at
+once.
+```bash
+vim -d <(grep foo bar) <(grep foo moose)
+```
+
## Argument parsing with `getopts`
The `getopts` builtin uses following global variables:
@@ -227,3 +235,4 @@ complete -F _foo foo
```
[dup2]: http://man7.org/linux/man-pages/man2/dup.2.html
+[psub]: https://tldp.org/LDP/abs/html/process-sub.html
diff --git a/src/tools/fish.md b/src/tools/fish.md
index 117ead2..fd1b2f7 100644
--- a/src/tools/fish.md
+++ b/src/tools/fish.md
@@ -87,6 +87,12 @@ echo "ls output: "(ls)
echo foo >? log
```
+### Process substitution
+Redirect output of multiple processes. Same as `<(..)` in bash.
+```sh
+diff (sort a | psub) (sort b | psub)
+```
+
## Control Flow
### `if` / `else`
```sh
diff --git a/src/tools/zsh.md b/src/tools/zsh.md
index a1302a4..f702655 100644
--- a/src/tools/zsh.md
+++ b/src/tools/zsh.md
@@ -174,6 +174,18 @@ echo ${(kv)vec} # a aa b bb
for k v in ${(kv)vec)}; do ...; done
```
+## I/O redirections
+
+See [bash - I/O redirection](bash.md#io-redirection)
+
+## Process substitution
+
+Process substitution allows to redirect the stdout of multiple processes at
+once.
+```bash
+vim -d <(grep foo bar) <(grep foo moose)
+```
+
## Argument parsing with `zparseopts`
```zsh