Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Anonymous functions don't show up well in "jobs" builtin output, except



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@xxxxxxxxxxxx
John Hawkinson




Messages sorted by: Reverse Date, Date, Thread, Author