zsh-workers
 help / color / mirror / code / Atom feed
* Anonymous functions don't show up well in "jobs" builtin output, except
@ 2022-10-24 21:49 John Hawkinson
  2022-10-25  8:23 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: John Hawkinson @ 2022-10-24 21:49 UTC (permalink / raw)
  To: zsh-workers

Hi.

I recently had a use-case where I needed to use an anonymous function shell one-liner to do some trickery with =() process substitution persisting for multiple commands (That is, () { thing1 $1; thing2 $1 } =(echo echo foo) ). I was surprised to find the resulting command was not meaningfully represented in the jobs builtin output.

I'm not 100% sure this rises to the level of "bug," but it is a bit annoying and would be nice to have corrected.

I saw this in zsh 5.8.1, but it reproduces in the git head (5b1c204c54e3ba41411e583ea649532b12977845):

jhawk@lrr ~ % zsh-dev --version
zsh 5.9.0.1-dev (arm-apple-darwin21.6.0)
jhawk@lrr ~ % zsh-dev -f       
lrr% cat 
^Z
zsh: suspended  cat
lrr% ( cat; )
^Z
zsh: suspended  ( cat; )
lrr% { cat; }
^Zzsh: suspended  cat
lrr% () { cat; } 
^Z
zsh: suspended  
lrr% jobs
[1]    suspended  cat
[2]    suspended  ( cat; )
[3]  - suspended  cat
[5]  + suspended  
lrr% () { cat; } &
[6] 81263
lrr% 
[6]  + suspended (tty input)  () { ... }


The suspension of the raw cat command ([1]), the subshell ([2]), and the list ([3]) all appear fine.
But the anonymous function does not. Not clear what happened to [4] but I guess it is [5].

It's notable that the same command-line when backgrounded explicitly with & appears to show up reasonably ([6]), even though when suspended manually with ^Z ([5]), it did not.


(There also seems to be something peculiar with respect to terminal settings getting screwed up in this process, where "reset" or "tput reset" or even cat<RET><ESC>[c<RET><CTRL-d> to get back to normal. Not sure what's up with that, and I think that's not in scope for this bug report.)

I have not attempted to craft a patch (or even inspect the code), but if it's helpful for your workflow I'm happy to do that. I am new to zsh development. (And honestly...almost new to zsh; back to it after a 28-year hiatus! Triggered by Apple, of course.)

Thanks.

--
jhawk@alum.mit.edu
John Hawkinson


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Anonymous functions don't show up well in "jobs" builtin output, except
  2022-10-24 21:49 Anonymous functions don't show up well in "jobs" builtin output, except John Hawkinson
@ 2022-10-25  8:23 ` Peter Stephenson
       [not found]   ` <Y1ewKOKQJ1AnvR92@louder-room.local>
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2022-10-25  8:23 UTC (permalink / raw)
  To: John Hawkinson, zsh-workers

> On 24/10/2022 22:49 John Hawkinson <jhawk@alum.mit.edu> wrote: I
> recently had a use-case where I needed to use an anonymous function
> shell one-liner to do some trickery with =() process substitution
> persisting for multiple commands (That is, () { thing1 $1; thing2 $1 }
> =(echo echo foo) ). I was surprised to find the resulting command was
> not meaningfully represented in the jobs builtin output.
>
> lrr% () { cat; }
> ^Z
> zsh: suspended

This is probably related to another continuing thread --- it's likely to
be because the anonymous function was originally running in the current
shell, and the entire shell was forked to continue running it in the
background.  This doesn't have the same job text a normal process would
have --- both a straight "cat" and "( cat )" are running as separate
processes from the start.

It's probably possible to do better but quite how hard it's going to be
dragging the job text round the houses I'm not sure.

pws


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Anonymous functions don't show up well in "jobs" builtin output, except
       [not found]   ` <Y1ewKOKQJ1AnvR92@louder-room.local>
@ 2022-10-25 10:05     ` Peter Stephenson
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2022-10-25 10:05 UTC (permalink / raw)
  To: John Hawkinson, zsh workers

> On 25/10/2022 10:45 John Hawkinson <jhawk@alum.mit.edu> wrote:
> > This is probably related to another continuing thread --- it's likely to
> 
> Which one, please? I had found "Bug report: `jobs` in `PROMPT` not showing
> latest suspend job" but it seemed to be a new regression and also fixed,
> and that doesn't line up with my issue. Thanks.

I'm referring to "problem with 'ls | less' shell function", which depends on
the same shell feature of forking to support a suspended shell function,
anonymous or otherwise, but the details are all different --- that issue
certainly wouldn't lead to a fix here.

pws


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-25 10:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-24 21:49 Anonymous functions don't show up well in "jobs" builtin output, except John Hawkinson
2022-10-25  8:23 ` Peter Stephenson
     [not found]   ` <Y1ewKOKQJ1AnvR92@louder-room.local>
2022-10-25 10:05     ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).