1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix process substitutions printing PIDs in profile scripts (#395)

- sh/args.c: A process substitution run in a profile script may print
  its PID as if it was a command spawned with '&'. Reproducer:
     $ cat /tmp/env
     true >(false)
     $ ENV=/tmp/env ksh
     [1]	730227
     $
  This bug is fixed by turning off the SH_PROFILE state while running
  a process substitution.

- sh/subshell.c: The SH_INTERACTIVE fix in 3525535e renders the extra
  check for SH_PROFILE redundant, so it has been removed.

- tests/io.sh: Update the procsub PIDs test to also check the result
  after using process substitution in a profile script.
This commit is contained in:
Johnothan King 2021-12-22 05:25:26 -08:00 committed by Martijn Dekker
parent 740a24a456
commit 3785a0685c
5 changed files with 13 additions and 6 deletions

View file

@ -590,10 +590,11 @@ result=$("$SHELL" -c 'echo ok > >(sed s/ok/good/); wait' 2>&1)
[[ $result == good ]] || err_exit 'process substitution does not work with redirections' \
"(expected 'good', got $(printf %q "$result"))"
# Process substitution in an interactive shell shouldn't print the
# process ID of the asynchronous process.
result=$("$SHELL" -ic 'echo >(true) >/dev/null' 2>&1)
[[ -z $result ]] || err_exit 'interactive shells print a PID during process substitution' \
# Process substitution in an interactive shell or profile script shouldn't
# print the process ID of the asynchronous process.
echo 'false >(false)' > "$tmp/procsub-envtest"
result=$(ENV=$tmp/procsub-envtest "$SHELL" -ic 'true >(true)' 2>&1)
[[ -z $result ]] || err_exit 'interactive shells and/or profile scripts print a PID during process substitution' \
"(expected '', got $(printf %q "$result"))"
# ======