From: Samir Benmendil <me@rmz.io>
To: zsh-users@zsh.org
Subject: fg does not resume most recent job when started from a function
Date: Wed, 20 Jan 2021 19:02:04 +0000 [thread overview]
Message-ID: <20210120190204.rvaqpedkt4cqrpa4@hactar> (raw)
[-- Attachment #1: Type: text/plain, Size: 1386 bytes --]
Hello,
When multiple jobs are being started via a function, suspending and
resuming them behaves a bit oddly. The most recently suspended job seems
to be placed at the end of the jobs queue and is therefore not the one
being resumed by a fg call.
For example:
% function print_s { watch echo $1 }
% print_s one # suspend command with ^Z
% print_s two # suspend command with ^Z
% jobs
[1] - suspended
[3] + suspended
% fg # resumes print_s two as expected, suspend it with ^Z
[3] - 214167 continued
[3] - 214167 suspended
[3] - 214167 suspended
% jobs
[1] + suspended
[3] - suspended
% fg # resumes print_s one?! suspend with ^Z
[1] - 214151 continued
[1] - 214151 suspended
[1] - 214151 suspended
% fg # resumes print_s two?! fg, ^Z will alternate between jobs
[3] - 214167 continued
[3] - 214167 suspended
[3] - 214167 suspended
Notice also that `jobs` does not list any command names.
Running the same watch command directly rather through a function
results in ^Z/fg behaving as expected, suspending/resuming the latest
job.
I've tried coming up with an example that would automatically suspend
the command by backgrounding it and reading from stdin.
% function read_bg { read & }
This does indeed suspend read immediately but the behaviour described
above is not exhibited.
Best Regards,
Samir
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
reply other threads:[~2021-01-20 19:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210120190204.rvaqpedkt4cqrpa4@hactar \
--to=me@rmz.io \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).