help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Unexpected behaviour in job control inside subshell envi


From: Chris F.A. Johnson
Subject: Re: [Help-bash] Unexpected behaviour in job control inside subshell environment
Date: Thu, 1 Dec 2016 18:42:01 -0500 (EST)
User-agent: Alpine 2.10 (DEB 1266 2009-07-14)

On Thu, 1 Dec 2016, Greg Wooledge wrote:

On Thu, Dec 01, 2016 at 12:55:04PM -0300, Diego Augusto Molina wrote:
So I came up with the following idea:

SLEEP_ARG=wrong-value;
(
  sleep "10${SLEEP_ARG}" &
  sleep 0.1; # Optional but recommended
  jobs -r 1;

Remember that job control is disabled in scripts (non-interactive shells)
by default.

As far as wrapping the sleep(1) command to validate arguments, I would
go with something more like this:

ver=$(sleep --version 2>&1)

$ ver=$(sleep --version 2>&1)
$ echo "$ver"
sleep: usage: sleep seconds[.fraction]


--
Chris F.A. Johnson, <http://cfajohnson.com>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]