Robert Elz wrote in
<[email protected]>:
| Date: Thu, 09 Nov 2023 21:04:28 +0100
| From: Steffen Nurpmeso <[email protected]>
| Message-ID: <20231109200428.8g9lz%[email protected]>
|
|| ash(1) and busybox ash(1) do not even support jobs -l in a function \
|| (yet).
|
|That seems unlikely, ash based shells mostly don't care whether the \
|commands
|they're running are in a function or not, except for those few commands for
|which that is important (like return, local, etc).
|
|Are you sure that you're not seeing the effects of running jobs in a
|subshell environment (in a command substitution) - where no jobs have
|yet been created in that environment. Modern shells allow jobs (like
|trap) there, as a way to get the parent shell's jobs (or traps), but
|even now (in the latest drafts) POSIX does not require that jobs works
|that way (it does for trap, in very limited cases).
That was taking me too literally. It seems monitor mode and all
its tracked jobs are not available in a subshell, not even within
{ ; }. ... Hmm. Well have i done this afternoon:
#?0|kent:tmp$ dash
#?0|kent:tmp$ LESS= less t.rc &
#?0|kent:tmp$ LESS= less t.sh &
#?0|kent:tmp$ jobs -l
[2] + 18950 Stopped (tty output) less t.sh
[1] - 18948 Stopped less t.rc
#?0|kent:tmp$ { jobs -l; }
[2] + 18950 Stopped (tty output) less t.sh
[1] - 18948 Stopped less t.rc
#?0|kent:tmp$ ( jobs -l; )
#?0|kent:tmp$ listem() {
> jobs -l
> }
#?0|kent:tmp$ listem
[2] + 18950 Stopped (tty output) less t.sh
[1] - 18948 Stopped less t.rc
#?0|kent:tmp$ $( listem )
#?0|kent:tmp$
So i would have to use output redirection in order to avoid
calling listem() in a $() construct.
It seems the simple issue is about to become a monster.
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)