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=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16820 invoked from network); 2 Mar 2022 09:44:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Mar 2022 09:44:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1646214296; b=KvTuSYiEt53uqv2eGioEeKfxPYaxXmp1YR+xhditCLkXQxmmHUqFcz21BJpU7gwKTX6Znl+X7e 4divbJBBLb917iwl4jVXdKrBi/oMUq2SjR0jSaZXnUp/fLCSZfbBi0OxL3GlIeqsumsKpdzhd0 hewokWlpkHORT1G0aTeluZ7roXZduBtytgAeIUbTibx0A4WX9AAuoTHgJG4Rr8hd5OzPz4c5bo swtdTdVnABQHxOdiDBvW3EnmyZL2T9Oz+hYnAIvRY7YG235Foa3BXB9cnpHuHrKS5KrY3dKfyJ sIkSCV42P24OuqziRzpOkm9ED/DJJgK4mNsozgo6im/HZA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.25; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1646214296; bh=i3aQT5+aqG1DjoMno56bh0z76sfcaZ0BCDMpwbct+2c=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Subject:Cc:To:From: Date:References:In-Reply-To:Message-ID:MIME-Version:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=EgLOij4bCE5QUljJJ+Ka6tG7ze4ffuq2KYW2MKCj7C5TLdcJ4jCHIfzppbnGBto+TQrUEBGQfS PcXtCBM3VmVs6HdHsJmb2vEq6zJn56W1UK2q0iHUYhKD3pee9Tnd2/69SCDCWxcdwDcFR0SVsi S7nVtw3flaOZZTXrWfE/4gwdba2ratb0QA0Gnr0I60fg92FpE0X0hUToobHj87tkN7IXBXLiDT INJVZAzsu+IZ+SDIZ+aGGS651jvx6FRqB0ZxVur7S0bhUDCwuhDRqPRQqlUM8779MZU7FCc965 fgZjnjOuFhgo23C/AkL7bYZpPbVzS4sl61g4EM+uBY1jlw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Uq8QWlWkCuqFYwV6AeCFspUFXUKD8rVT8doqwCwxL0c=; b=oGm3Jpqo6N0boE4F877iRSINfb hzCrl97Jv0nKrR/uZU1CPmOD7lvFRLQaBXq1eftl1QVGfgPVkjl32Xqmqb9A56khElTVhhIDF5EVf 2V2KEc2M0/ENRjQfvFnRsY0vYOhTcnaoJCdpQQ+ff3un+NdP3Tb5hVhSpYFkVXPI4NXDv5HvN3alA l17XgD9OmbyUYvBBMY1i1ES2IwGEIBU31tIoQVlpoK8cRBIW06P1DzgOJvect6d8V33lypSnAQNxX 7Fx354baGhxPLVI2+sgZ4362nUVQDedKU6/CcnetOgBhLtybgpS/kLIa6c/KfLTuesyGsTywUoLr3 RvfCoTkg==; Received: from authenticated user by zero.zsh.org with local id 1nPLXT-000CC1-LI; Wed, 02 Mar 2022 09:44:55 +0000 Authentication-Results: zsh.org; iprev=pass (out1-smtp.messagingengine.com) smtp.remote-ip=66.111.4.25; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from out1-smtp.messagingengine.com ([66.111.4.25]:44079) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nPLWx-000BqW-D3; Wed, 02 Mar 2022 09:44:23 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B5D995C040D; Wed, 2 Mar 2022 04:44:22 -0500 (EST) Received: from imap46 ([10.202.2.96]) by compute4.internal (MEProxy); Wed, 02 Mar 2022 04:44:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; bh=Uq8QWlWkCuqFYwV6AeCFspUFXUKD8rVT8doqwC wxL0c=; b=MWi2nYF1wqgO3+uJeii495MuC7rzGl5MxGiTgVeGbzd879xZJ4coYa KtUV+nel/cJxyvmWH4wO+6NcHHxKnyx8IvlzVxGY6qSAT3a9e9+vHzkgGXDKH2Qm sROHifRsxBGwQqRZ4p2YGN6OxtdQpaq9iPzRWGiaqWWeb2z7JjJW/t80zzP4oMC1 Zt6B4wY/v3VD8oMfAbO0pUK4ACcdV3iUQZEhbQsoPRhWSyGQ2EkcNWl1AHorvvF6 XziHt+j4Y3ZfbdQV5VwgSw0N3bdNRBFaiBzjODGRifxT7Iz3MAEPfyMf/kyvy6tR MydthEg8GT2ftHVVMiRncBZSKPMZAjRg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=Uq8QWlWkCuqFYwV6AeCFspUFXUKD8rVT8doqwCwxL 0c=; b=TxKkdK77aRHwmksjwIv7LWpC0m44MAlzQz000CWRSCDKCjKkiCw3sJiQ0 F1TIh9zthFK1fp1AtepUv0HdmVryqJh5NDtuLivooEAUb+jyDiRytcRM/MF4IIkZ TF3kb5Mb9g1RMhQSoXu6xVaCjUDFTPJLZDAz1wjdf7dqZ6sE7rxlk1pwPtKl81nd /csC+df1dmxAee+wdL85+NA/fv2bCbw8/uqiNiyFT+KfpQvGNvuAcCB7fQH0nAOd BEQv1pUOqdU+1sP/MaktwD04z94uGXiZT2D6Q3ZglQwPMKkyiUrPP3RBnYsRdJYj tY8VrryK/s9D7TOkb5FvUZ7eU9h5w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddruddtgedgtdehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfffgr nhhivghlucfuhhgrhhgrfhdfuceougdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgrmh gvqeenucggtffrrghtthgvrhhnpeefhfekfeevieelleehiefftdekudejledvhfdtjedt geegvdeuffefleehhfdvgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8663A1EE007B; Wed, 2 Mar 2022 04:44:22 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4778-g14fba9972e-fm-20220217.001-g14fba997 Mime-Version: 1.0 Message-Id: <18fc86e5-467d-4753-9f82-6a3073874334@www.fastmail.com> In-Reply-To: <1912988517.1110378.1646131250968@mail2.virginmedia.com> References: <1912988517.1110378.1646131250968@mail2.virginmedia.com> Date: Wed, 02 Mar 2022 09:44:02 +0000 From: "Daniel Shahaf" To: zsh-workers Cc: "Carl Agrell" Subject: Re: [Bug] $jobstates does not work in $() Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 49784 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Peter Stephenson wrote on Tue, 01 Mar 2022 10:40 +00:00: >> On 01 March 2022 at 00:46 Carl Agrell wrote: >>=20 >>=20 >> It appears that zsh/parameter's $jobstates is always empty inside $(), >> probably because it's a subshell of some sort. `jobs` still works >> however, making it rather incongruous. Having access to $jobstates >> would be useful for prompts for example, rather than having to parse >> the output of `jobs`. >>=20 >> To reproduce: >> =E2=9D=AF sleep 1000 & >> [1] 210460 >> =E2=9D=AF jobs >> [1] + running sleep 1000 >> =E2=9D=AF echo $jobstates >> running:+:210460=3Drunning >> =E2=9D=AF echo $(jobs) >> [1] + running sleep 1000 >> =E2=9D=AF echo $(echo $jobstates) >> (empty) > > Yes, we store the old job table for use with the builtin, but not with > parameters, which is inconsistent. > > What is probably worse is that some parameters (not, as it happens, > jobstates) call getjob(), which does have the logic to switch to the o= ld > table, but then make no attempt to switch to the right table for the > remainder of the processing, which could result in undefined behaviour. > > This fixes it up with a function selectjobtab() used to query job stat= es > in the parameter functions as well as getjob(). > Is this testable? Sorry, haven't got time to write a test myself right = now. Cheers, Daniel > --- a/Src/Modules/parameter.c > +++ b/Src/Modules/parameter.c > @@ -1244,19 +1244,19 @@ histwgetfn(UNUSED(Param pm)) > @@ -1269,22 +1269,25 @@ static HashNode > @@ -1297,22 +1300,25 @@ static void > @@ -1323,7 +1329,7 @@ scanpmjobtexts(UNUSED(HashTable ht), ScanFunc=20 > @@ -1335,14 +1341,14 @@ pmjobstate(int job) > @@ -1371,21 +1377,24 @@ static HashNode > @@ -1398,22 +1407,25 @@ static void > @@ -1424,11 +1436,11 @@ scanpmjobstates(UNUSED(HashTable ht), ScanFunc=20 > @@ -1437,21 +1449,24 @@ static HashNode > @@ -1464,22 +1479,25 @@ static void > --- a/Src/jobs.c > +++ b/Src/jobs.c > @@ -98,10 +98,12 @@ mod_export int jobtabsize; > @@ -1894,6 +1896,26 @@ setcurjob(void) > @@ -1904,13 +1926,7 @@ getjob(const char *s, const char *prog)