-
-
Save glyph/2b34dca47145065baa60a0c98207f8d8 to your computer and use it in GitHub Desktop.
created by https://github.com/tr3buchet/gister
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
debugwhat () { | |
local debug1="$1"; | |
echo "start debugging: ${debug1}"; | |
while read x; do | |
echo "debug ${debug1}: ${x}"; | |
done; | |
echo "end debugging: ${debug1}"; | |
} | |
multidebug () { | |
A="$1"; | |
B="$2"; | |
C="$3"; | |
X="$(echo "hi")"; | |
( | |
(echo "this subshell closes $A $B $C in bash, but not zsh";) | |
echo "one" > "${A}"; | |
echo "two" > "${A}"; | |
echo "three" > "${B}"; | |
echo "four" > "${B}"; | |
echo "five" > "${C}"; | |
) | |
echo "done" > "${A}"; | |
} | |
multidebug >(debugwhat one) >(debugwhat two) >(debugwhat three); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start debugging: one | |
start debugging: two | |
start debugging: three | |
this subshell closes /dev/fd/13 /dev/fd/14 /dev/fd/15 in bash, but not zsh | |
debug one: one | |
debug one: two | |
debug two: three | |
debug three: five | |
debug two: four | |
debug one: done | |
end debugging: three | |
end debugging: two | |
end debugging: one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start debugging: one | |
start debugging: two | |
start debugging: three | |
this subshell closes /dev/fd/63 /dev/fd/62 /dev/fd/61 in bash, but not zsh | |
end debugging: three | |
redirmany.zsh: line 18: 1: Bad file descriptor | |
redirmany.zsh: line 19: 1: Bad file descriptor | |
redirmany.zsh: line 20: 1: Bad file descriptor | |
redirmany.zsh: line 21: 1: Bad file descriptor | |
redirmany.zsh: line 22: 1: Bad file descriptor | |
end debugging: two | |
redirmany.zsh: line 24: 1: Bad file descriptor | |
end debugging: one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment