Prerequisites
Steps to reproduce
It is understood that the newly introduced, Unix-only Switch-Process cmdlet (alias exec) is not designed to have full feature parity with the exec built-in in POSIX-compatible shells, notably not with respect to supporting stream redirections.
However, making the replacement process inherit the caller's environment is an important part of exec functionality (and it is how it works in POSIX-compatible shells).
Related discussion predating Switch-Process:
# Run on macOS or Linux.
# Note the use of `exec`; if you remove it, 'bar' prints as expected
pwsh -nop -c '$env:FOO=''bar''; exec /bin/sh -c ''echo $FOO'''
Expected behavior
Actual behavior
(no output)
Error details
No response
Environment data
PowerShell Core 7.3.0-rc.1 on Unix-like platforms
Visuals
No response