Sample Header Ad - 728x90

Why do backgrounded commands in Zsh functions not show correctly in jobs?

4 votes
1 answer
211 views
In Bash 5.2, the output of jobs after either of the following is identical modulo job numbers:
sleep 3
# press C-z
s() { sleep 3; }
s
# press C-z
In both, jobs produces something like
+  Stopped                sleep 3
--- In Zsh 5.9 (x86_64-apple-darwin20.6.0), the first produces similar enough output containing the sleep command:
+ suspended  sleep 3
The second produces almost useless output:
+ suspended
--- I have [lots of functions that invoke Vim with different arguments or completions](https://github.com/benknoble/Dotfiles/blob/854f9498cb90af3b84cb961a9e97cf0009970f31/links/zsh/vim.zsh) ; suspending Vim during the execution of any of them via C-z or :suspend puts such a useless entry in jobs. It's not uncommon for me to have 2 or more such jobs, in which case it is rather difficult to keep them straight. Why does Zsh do this and is there a way for me to fix it?
Asked by D. Ben Knoble (552 rep)
Nov 15, 2022, 06:38 PM
Last activity: Jul 26, 2024, 03:16 PM