The -bg flag launches the job in the background without any way to capture output or errors.
If the command returns a non-zero exit status and -bg is not used, a command line error will be signalled. The actual exit status is not available.
The wait-for-shell
command is similar to shell
. It can be used in a script branch, allowing other script branches to execute in parallel while waiting for the command to finish.
When used in an expression (without the -bg flag), any messages printed to standard output will be returned:
$today = (shell "date +%F")
on Linux; or
$today = (shell "date /t")
on Windows.