bug-bash
[Top][All Lists]
Advanced

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

Re: Bug: different behavior between "jobs -l" and "builtin jobs -l"


From: Eric Blake
Subject: Re: Bug: different behavior between "jobs -l" and "builtin jobs -l"
Date: Tue, 21 Mar 2017 12:27:25 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

On 03/21/2017 12:08 PM, Greg Wooledge wrote:

> The code that makes bash behave differently when "jobs" is one of the
> commands in a pipeline/subshell is kind of a hack.  It's probably not
> extremely well known outside of this mailing list, but I suspect many
> people have used it without realizing what it is.  It's a fairly intuitive
> hack.

And it's for more than just 'jobs' - at least 'trap' relies on it, too.

> 
> I've got no strong opinions about whether the "jobs hack" should be
> documented.

POSIX documents the 'jobs'/'trap' hack thus:

When a subshell is entered, traps that are not being ignored shall be
set to the default actions,
except in the case of a command substitution containing only a single
trap command, when the
traps need not be altered. Implementations may check for this case using
only lexical analysis;
for example, if `trap` and $( trap -- ) do not alter the traps in the
subshell, cases such as
assigning var=trap and then using $($var) may still alter them.

For more background on this, see:
http://austingroupbugs.net/view.php?id=53

although that bug specifically mentions 'trap', and concludes that a
separate bug may need to be opened (which I could not find) giving the
same treatment to 'jobs'.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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