Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What he meant is that <strong>job control is by default turned off in non-interactive mode</strong> (i.e. in a script.)</p> <p>From the <code>bash</code> man page:</p> <pre><code>JOB CONTROL Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) their execution at a later point. A user typically employs this facility via an interactive interface supplied jointly by the system’s terminal driver and bash. </code></pre> <p>and</p> <pre><code> set [--abefhkmnptuvxBCHP] [-o option] [arg ...] ... -m Monitor mode. Job control is enabled. This option is on by default for interactive shells on systems that support it (see JOB CONTROL above). Background processes run in a separate process group and a line containing their exit status is printed upon their completion. </code></pre> <p>When he said "is stupid" he meant that not only:</p> <ol> <li>is job control <em>meant</em> mostly for facilitating interactive control (whereas a script can work directly with the pid's), but also</li> <li>I quote his original answer, <em>... relies on the fact that you didn't start any other jobs previously in the script which is a bad assumption to make</em>. Which is quite correct.</li> </ol> <p><strong>UPDATE</strong></p> <p>In answer to your comment: yes, nobody will stop you from using job control in your bash script -- there is no hard case for <em>forcefully disabling</em> <code>set -m</code> (i.e. yes, job control from the script will work if you want it to.) Remember that in the end, especially in scripting, there always are more than one way to skin a cat, but some ways are more portable, more reliable, make it simpler to handle error cases, parse the output, etc.</p> <p>You particular circumstances may or may not warrant a way different from what <code>lhunath</code> (and other users) deem "best practices".</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload