The short answer is that you cannot. Bash always prints the status of foreground jobs. The monitoring flag is used only for background jobs and only for interactive shells, and not for scripts.
see notify_of_job_status () in jobs.c.
As you say, you can redirect, so a standard error points to / dev / null, but then you skip any other error messages. You can make this temporary by doing a redirection in the subshell that runs the script. This leaves the source environment separate.
(script 2> /dev/null)
which will lose all error messages, but only from this script, and not from anything else in this shell.
You can save and restore the standard error by redirecting a new filedescriptor to indicate there:
exec 3>&2
But I would not recommend this - the only potential from the first is that it saves the sub-shell call, being more complex and maybe even changing the behavior of the script if the script changes the file descriptors.
EDIT:
For a more suitable answer to the question of answer Mark Edgar
wnoise Sep 17 '08 at 10:07 2008-09-17 10:07
source share