From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15524 invoked from network); 20 Jan 2021 19:02:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Jan 2021 19:02:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1611169365; b=LrGmYOXoYOP8nfda4SLPXrZdEz/ZlGVacwVRp+1P100mWPPPKKTnuMokMpw0mhQa9WulfFy3pL 2hE/JuwnariSTtj5xW+HJOrueahxdPJwvuvRs5wlpC0DoowhajsTzWHVVZxxzJ/g3jdRDsvUrC W8dDcp5c1nISRBlIG6St2GHh4DwiRYuSqWbKn5fGNY6w4v2rqnM8NAFk30AuKHzEK1HgHSErkf YrB6Sl7nmJNNmnnFLXVqZo/usvdez6FoPMk6YMlY9ERwTtwp+2kf1xLr/rjbXctEfi/F9ZhBA9 RkF65+AK3ZswR9GbAMu2avuwzHL82OJqPLxvrt0sZS1T3w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wilbur.contactoffice.com) smtp.remote-ip=212.3.242.68; dkim=pass header.d=rmz.io header.i=me@rmz.io header.s=20200308-xcrr header.a=rsa-sha256; dmarc=pass header.from=rmz.io; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1611169365; bh=gq7/w5eDKr0CAPsSY9p3SIYvXadGZNrmJkpviECONOQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:Message-ID:Subject:To:From:Date: DKIM-Signature:DKIM-Signature; b=XhAmhyudX2I5I+TjxUBScaLy+oJbNnhmMImxysL3wxjjfFTIlkpPtheVU6jMrWgS3JiEC6I8Bw kxXHghG6C1az9opsK+n3UsUcCvakJxaljAXIqsAOLKH4HYj+Hjww5b7BXcevgavPGvbUH7jaVX duUBbBa/KVILVyfWLI1ZuiaMy7m+EmBqlZs+kr3jHtOJ3j4UxjkBnAmJVEHQRttZdr9UO4lgLe SZQC37aqNl2vmq+tVuKhMRWSB/5xSeVAxUAv2+BE7BVC9bej32lqP+WyqTmUCzTn34+A0NZoMb pUQ660hnEQSZPyFTxNpUzCcL0jNrLInUpX/Fa2f/fHmXDg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=EyUbCaWUnhBxbpNstmZr34JWvFrMpL4H5pzRLVJjkcI=; b=HHKzHUEE9MhcPHdZ5/hx4U/Red pXEfjrtSTV1mpD3fGNSGTLyaiHkOMy1AkJeT/T2pn/Godv3GvRVVHQvZeij+0Go/rhp11C13DHpJ0 c8F/Not70iPKVOB/v/jFRJUYUog6z1V9dSqPRTqFXWxipJ2C9AASlg6F7J8b9fzNcuHJHpwosFwbb Lk3MO3d0wTU8HGv112YOY6wKDRhOGpOuFd7rzaMhSI7aXtLiVN6eKFznd3F5J5bHqFMCCB6W23pLf rwXsXZHJF8HsMCfr9vIj6SrQLcYQpF1LDHQvSNZjSTbDikKKDOFrZ4jj8AEKKlqhzPvWsojG7vQ/Z U4Nzv1qQ==; Received: from authenticated user by zero.zsh.org with local id 1l2Ikf-000KxQ-9a; Wed, 20 Jan 2021 19:02:45 +0000 Authentication-Results: zsh.org; iprev=pass (wilbur.contactoffice.com) smtp.remote-ip=212.3.242.68; dkim=pass header.d=rmz.io header.i=me@rmz.io header.s=20200308-xcrr header.a=rsa-sha256; dmarc=pass header.from=rmz.io; arc=none Received: from wilbur.contactoffice.com ([212.3.242.68]:40032) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1l2Ik5-000KaN-IN; Wed, 20 Jan 2021 19:02:10 +0000 Received: from smtpauth1.co-bxl (smtpauth1.co-bxl [10.2.0.15]) by wilbur.contactoffice.com (Postfix) with ESMTP id 8FADF2371; Wed, 20 Jan 2021 20:02:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1611169328; s=20200308-xcrr; d=rmz.io; i=me@rmz.io; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type; l=2501; bh=EyUbCaWUnhBxbpNstmZr34JWvFrMpL4H5pzRLVJjkcI=; b=LaaqIeUgb6jwPqR6Rg5VnYoBuzMTC4bubC1Bag7ks6XvR9CZDXUVVPURlj4ZoRkf uq8O5BWW5/er7NK9Wy5GXY72hl0MkpylcmlILpL+IHlb9/egqHFdsWL2+JsWjIpVW/j cqqrRckJNyboK8Z6mVVCM+NHrXscx+3QHPGWwZ5hftsRjpGOIBSVEv/CFilLc1U+sRJ zwsMYyhK+yrDkXoIt4DfMf26hV7PW5xI0qsz1XAvWJ3HsV0tG3VQO1dKInZjs7dFeDN aHF4LeB/Z/MZYlE0v9veAagsebnT3c57etfrbZFOP0ExvSgkZSjus4iJepVq3YTmNBL nN3Ez0SrAg== Received: by smtp.mailfence.com with ESMTPA ; Wed, 20 Jan 2021 20:02:05 +0100 (CET) Date: Wed, 20 Jan 2021 19:02:04 +0000 From: Samir Benmendil To: zsh-users@zsh.org Subject: fg does not resume most recent job when started from a function Message-ID: <20210120190204.rvaqpedkt4cqrpa4@hactar> X-Clacks-Overhead: GNU Terry Pratchett MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sgykjw4abd7qpdme" Content-Disposition: inline X-ContactOffice-Account: com:225813835 X-Seq: 26405 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: --sgykjw4abd7qpdme Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, When multiple jobs are being started via a function, suspending and=20 resuming them behaves a bit oddly. The most recently suspended job seems=20 to be placed at the end of the jobs queue and is therefore not the one=20 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 =20 [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 =20 [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=20 results in ^Z/fg behaving as expected, suspending/resuming the latest=20 job. I've tried coming up with an example that would automatically suspend=20 the command by backgrounding it and reading from stdin. % function read_bg { read & } This does indeed suspend read immediately but the behaviour described=20 above is not exhibited. Best Regards, Samir --sgykjw4abd7qpdme Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEO8iRpJat6BxHTtT0gmAAVevIWpMFAmAIfikACgkQgmAAVevI WpOfIQ/8DUUbS5ywvchWYlZqc0B7Bno7yMCfoV3kWg0N6ZnQyECv0EKUOlm5JlUr R1knAftXGo9RULozGFge/th1eu323C/5uoPNsvM8cD+DUo4R0uRk3ZTyqgGgy7xX XeODIfBFlZurARwo69xsvZNohu0TlRR8j9PrKlV+lFZWOvRSRq+Fl6PX07CzEnaC EPMOAN3rSt6IpZtTYwdjAj62Bo6rHkQ/7sX63PVfDwC2UNmno2AgVQrNJTe5xZhu rdr2DpyTMRXe9viLGXIbyCNfpIR6UL5Ilf/2SDbiDFllKbPg4jwB5WxjfthCk4tE 0npvQAjqEmWgnlQqCr8m2cwcEia5iQJ9mCC3jJzrOY6qLjkrMXeWND4ENShmqfsv BQfAGdZeeY9/oi0CrS8TU5zKbCh7HmA58oAkfxOQVhDA3meziRirf1tQucSRCCdy P+jm1yu+TBXTUOAqWkHAypKSfIHl0sWhTtKsERGjzObYR6FDcdi9o9fsp9MbQTDo sgJKOfdaZllmS4uwlFLFnVz5xnsCKtZkyZWhAJEGPnB06IXtZQy3VUyNFtGSlq9J jiUTEBSCyKLCZrJvurK5nZq1qUEi5afpuxQAEZDHQwgC0mOZ8LlaJfoDrWyhVLwq lg/UoU4L9nWjK1PJx/mvbQnBiDakJJAghwPesc5n7UPbVcwgUyw= =GZ67 -----END PGP SIGNATURE----- --sgykjw4abd7qpdme--