bug-bash
[Top][All Lists]
Advanced

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

Re: Idea: jobs(1) -i to print only :%ID:s


From: Steffen Nurpmeso
Subject: Re: Idea: jobs(1) -i to print only :%ID:s
Date: Fri, 10 Nov 2023 00:02:33 +0100
User-agent: s-nail v14.9.24-563-g944131280a

Robert Elz wrote in
 <7989.1699564965@jacaranda.noi.kre.to>:
 |    Date:        Thu, 09 Nov 2023 21:04:28 +0100
 |    From:        Steffen Nurpmeso <steffen@sdaoden.eu>
 |    Message-ID:  <20231109200428.8G9Lz%steffen@sdaoden.eu>
 |
 || 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)



reply via email to

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