Sujet : Re: (bash) How (really!) does the "current job" get determined?
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.unix.shellDate : 04. Oct 2024, 03:40:06
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20241003170607.397@kylheku.com>
References : 1
User-Agent : slrn/pre1.0.4-9 (Linux)
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/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca