[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
A few possible process substitution issues
From: |
Dan Douglas |
Subject: |
A few possible process substitution issues |
Date: |
Mon, 25 Mar 2013 22:25:35 -0500 |
User-agent: |
KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; ) |
Hello,
1. Process substitution within array indices.
The difference between (( 1<(2) )) and (( a[1<(2)] )) might be seen as
surprising.
Zsh and ksh don't do this in any arithmetic context AFAICT.
Fun stuff:
# print "moo"
dev=fd=1 _[1<(echo moo >&2)]=
# Fork bomb
${dev[${dev='dev[1>(${dev[dev]})]'}]}
2. EXIT trap doesn't fire when leaving a process substitution.
$ ksh -c '[[ -n $(< <(trap "tee /dev/fd/3" EXIT)) ]] 3>&1 <<<works ||
echo "fail :("'
works
$ zsh -c '[[ -n $(< <(trap "tee /dev/fd/3" EXIT)) ]] 3>&1 <<<works ||
echo "fail :("'
works
$ bash -c '[[ -n $(< <(trap "tee /dev/fd/3" EXIT)) ]] 3>&1 <<<works ||
echo "fail :("'
fail :(
3. Can't wait on a process substitution.
ksh appears to be able to wait on a process substitution. Bash and Zsh can't,
but I'm not sure why.
$ ksh -c '{ { : <(sleep 1; printf 1 >&2); } 2>&1; wait $!; printf 2; }
| cat; echo'
12
$ bash -c '{ { : <(sleep 1; printf 1 >&2); } 2>&1; wait $!; printf 2; }
| cat; echo'
bash: wait: pid 9027 is not a child of this shell
21
At least, this is a confusing error, because that actually is a direct child
of the shell that runs the wait. Process substitutions do set $! in Bash, not
in Zsh.
--
Dan Douglas
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- A few possible process substitution issues,
Dan Douglas <=