1.1 KiB
1.1 KiB
coproc
Bash ingebouwd commando voor het maken van interactieve asynchrone subshells. Meer informatie: https://www.gnu.org/software/bash/manual/bash.html#Coprocesses.
- Voer een subshell asynchroon uit:
coproc { {{commando1; commando2; ...}}; }
- Maak een coprocess met een specifieke naam:
coproc {{naam}} { {{commando1; commando2; ...}}; }
- Schrijf naar de
stdinvan een specifiek coprocess:
echo "{{invoer}}" >&"${{{naam[1]}}}"
- Lees van de
stdoutvan een specifiek coprocess:
read <&"${{{naam[0]}}}" {{variabele}}
- Maak een coprocess dat herhaaldelijk
stdinleest en opdrachten op de invoer uitvoert:
coproc {{naam}} { while read {{regel}}; do {{commando1; commando2; ...}}; done }
- Maak een coprocess dat herhaaldelijk
stdinleest, voert een pipeline uit op de input en schrijf de output naarstdout:
coproc {{naam}} { while read {{regel}}; do {{echo "$regel"}} | {{commando1 | commando2 | ...}} | cat /dev/fd/0; done }
- Maak en gebruik een coprocess dat
bcuitvoert:
coproc BC { bc --mathlib; }; echo "1/3" >&"${BC[1]}"; read <&"${BC[0]}" output; echo "$output"