Summary
When executing a function in a subshell: the output is lost when a previous line in the function redirects to stderr while not having any output.
Minimal reproducer
#!/usr/bin/ksh
function echo_devnull {
echo "DEVNULL" >/dev/null
}
function func {
echo_devnull >&2
echo "FUNC"
}
OUT=$(func)
echo "OUT: ${OUT}"
Expected: OUT: FUNC
Actual: OUT: (empty)
In OUT=$(func), output from func is lost when a prior line in func runs the customer pattern echo_devnull >&2 (redirect that call’s stdout to stderr) and echo_devnull itself sends stdout to /dev/null. The following echo "FUNC" should appear in OUT but OUT is empty. bash is OK.
Reproduced on dev 4c391d.
Notes
Downstream indicated behaviour was OK on ksh-1.0.0~beta.1 and fails on current 1.0.6 / 1.0.10 version
Summary
When executing a function in a subshell: the output is lost when a previous line in the function redirects to stderr while not having any output.
Minimal reproducer
Expected:
OUT: FUNCActual:
OUT:(empty)In
OUT=$(func), output fromfuncis lost when a prior line infuncruns the customer patternecho_devnull >&2(redirect that call’s stdout to stderr) andecho_devnullitself sends stdout to/dev/null. The followingecho "FUNC"should appear inOUTbutOUTis empty. bash is OK.Reproduced on
dev4c391d.Notes
Downstream indicated behaviour was OK on
ksh-1.0.0~beta.1and fails on current 1.0.6 / 1.0.10 version