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: Greg Wooledge
Subject: Re: [Help-bash] Unexpected behaviour in job control inside subshell environment
Date: Thu, 1 Dec 2016 11:29:34 -0500
User-agent: Mutt/1.4.2.3i

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)
if [[ $ver = *GNU* ]]; then
  : fractions are allowed
else
  : fractions are probably going to blow up
fi

Actually *calling* sleep(1) with wacky arguments to see how long it
takes to die is pretty suboptimal, I should think.



reply via email to

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