Deutsch   English   Français   Italiano  
<20241003170607.397@kylheku.com>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups: comp.unix.shell
Subject: Re: (bash) How (really!) does the "current job" get determined?
Date: Fri, 4 Oct 2024 02:40:06 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <20241003170607.397@kylheku.com>
References: <vdn864$2p69n$1@news.xmission.com>
Injection-Date: Fri, 04 Oct 2024 04:40:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="92a9723e1b72d77d77e21513faad2485";
	logging-data="98070"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX199vCrRCn+HqxUgMVw1UeyYYxmQDFT5uEg="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:dTGqM/SNiA0lrJSBttmm5vUhrqo=
Bytes: 2263

On 2024-10-03, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> Note: This is a "How do things really work - in the real world?", rather
> than a "What does the manual say about how things work?" sort of thread.
>
> The manual says the answer is "The job most recently started in the
> background or most recently stopped."  This is not always the case.
>
> Observe (this is bash version 5.2.15) (and "j" is aliased to "jobs -l"):

It looks buggered.

>  $ j
> [1]+ 20914 Stopped (signal)        sudo bash

This is now most recently stopped.

>  $ sleep 100 & j

This is now most recently started in the background, therefore the
documentation specifies that it is now the current job.

It must be that Bash has no test cases covering the documented
requirements in this area adequate enough to catch what you have found.

Is this automatically tested at all?

Testing interactive job control features pretty much requires Bash to be
behind a pseudo-tty; driven by expect or something like it.

(Or else at least a unit test is required where the function that
identifies the current job is tested in isolation, with the various
conditions mocked up: suspended job introduced while existing job is
stopped, etc.)

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca