Created
November 2, 2012 16:47
-
-
Save ormaaj/4002611 to your computer and use it in GitHub Desktop.
trap scope
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
#!/usr/bin/env bash | |
# bash: line 3: declare: v: readonly variable | |
for fd in {a..d}; do | |
echo "$fd" | |
bash -x /dev/fd/"${!fd}" | |
done {ofd}<&0 <<\EOFA {a}<&0 <<\EOFB {b}<&0 <<\EOFC {c}<&0 <<\EOFD {d}<&0 <&${ofd} | |
tt() { typeset -r v=; } | |
t() { tt; } | |
ff() { | |
typeset -r v= | |
exit | |
} | |
f() { ff; } | |
trap t EXIT | |
f | |
EOFA | |
tt() { typeset -r v=; } | |
t() { tt; } | |
ff() { | |
typeset -r v= | |
exit | |
} | |
f() { ff; } | |
trap t EXIT; | |
f | |
EOFB | |
tt() { typeset -r v=; } | |
t() { tt; } | |
ff() { | |
typeset -r v= | |
exit | |
} | |
trap t EXIT; | |
ff | |
EOFC | |
tt() { typeset -r v=; } | |
ff() { | |
typeset -r v= | |
exit | |
} | |
f() { ff; } | |
trap tt EXIT; | |
f | |
EOFD | |
# vim: set fenc=utf-8 ff=unix ts=4 sts=4 sw=4 ft=sh nowrap et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment