On Fri, Jul 24, 2020 at 4:46 PM Dominique Martinet <[email protected]> wrote: > FWIW, bash (and zsh, ksh etc) will optimise the last command call of a > script to not fork, `bash -c 'exec foo'` is the same as `bash -c 'foo'` > > (for some reason it doesn't in the subshell though so that one makes a > difference; you can check with e.g. `strace -f -e clone bash -c ...`) > > > Simpler shells e.g. dash or busybox ash don't, but they don't support > the pipe substitution syntax either so I guess it doesn't matter here.
Right, I observed the same thing when I was testing this, but figured it was better to be explicit in both cases. thinkpad ~ # strace -f -e clone /bin/bash -c '/usr/bin/wg syncconf wgnet0 <(/usr/bin/wg-quick strip wgnet0)' 2>&1 | grep clone | wc -l 3 thinkpad ~ # strace -f -e clone /bin/bash -c 'exec /usr/bin/wg syncconf wgnet0 <(/usr/bin/wg-quick strip wgnet0)' 2>&1 | grep clone | wc -l 3 thinkpad ~ # strace -f -e clone /bin/bash -c 'exec /usr/bin/wg syncconf wgnet0 <(exec /usr/bin/wg-quick strip wgnet0)' 2>&1 | grep clone | wc -l 2
