Created
January 23, 2012 07:29
-
-
Save ormaaj/1661392 to your computer and use it in GitHub Desktop.
Bash parsing of redirects on exported functions
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 | |
set -x | |
f() { | |
echo 'hi' | |
} >&${1} | |
{ f 3; cat; } <<<'' 3>/dev/stdin | |
export -f f | |
export -pf | |
PS4='* ' BASH_XTRACEFD=4 bash -xc 'f 3; cat' <<<'' 3>/dev/stdin 4>&2 | |
[[ -f 3 ]] && cat ./3 | |
# vim: set fenc=utf-8 ff=unix ts=4 sts=4 sw=4 ft=sh nowrap et: |
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
~ $ rm 3; ./exbug | |
+ f 3 | |
+ echo hi | |
+ cat | |
hi | |
+ export -f f | |
+ export -pf | |
f () | |
{ | |
echo 'hi' | |
} &>${1} | |
declare -fx f | |
* PS4='* ' | |
* BASH_XTRACEFD=4 | |
+ bash -xc 'f 3; cat' | |
* f 3 | |
* echo hi | |
* cat | |
+ [[ -f 3 ]] | |
+ cat ./3 | |
hi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment