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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 720 invoked from network); 20 Jun 2022 19:54:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Jun 2022 19:54:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1655754865; b=fwlWV55e6EdfJywFMmY+/TE6c9YoA+GbqRc/ojSAUv/4y1T6pglWDjPLsBhGZfSEFkAWpXfeJL +VeVxAbvH9mX9vuBsdxETbtH7pso4B6KQ3lqJqyxu3XNARQpAY8/WHd9ceeejjAdoFOB1ChQ+u tuGRIV66SB0xsDu2yovpwms2ko61yAL4ahomNyYrVAUvXWpp28skNuEVdMpY3o49zJ8a1NkNFC bw5H7yflUDMMJpqsPQ2+BvmlNF/bt/mQC3Ba0H8bM/6oE3dn5HtaWS7PLqL18wHzybuWHW8xRq 3eFyaa2c2uvfSRCkOjhEdCU+gJhAngVIAtCUQErYG2iRSQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1655754865; bh=vQNJndTg1cNbuWV+kIOx0srx/vH3Kl+1frf+lzWODjI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:DKIM-Signature; b=C1UCHt6kGhtnsTSkTg6lETeqbg2bfKLbHw7Rlhzh+zET6qBAnMKTygWxacuvqugE0agTxGdLtY Nst53UQPT8a0Mv0/UHcjfnTmdISnAAP6yj2VCD6g8YZo0O9E4N+ONcYIkox8mPYlrrUthkiMYZ RVJ91aJIofjfeyIzDvxCxCMeUVDpuhX3Vn4VdEcIkXGNuDGQDKJfTjPh5Dw2Gs0fsu0WBLgayF KBdHkVRitM8jRg3aluwTGwf3rOEWB+KMyaizl65ge18nIAbDLlgKEGsPe6/jJICVihQ7PhBQXw LyUu7E7mMNTL2mggcXPiaCSgjc0IYOZD9uYOj2Nlv/580g==; 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:In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=HQtXqw5BS3K+Gg0wA7F3h4F5Wihh3ejkFEyNDHtAyE4=; b=qye/2sNwV0ZntI6ST0Y6F75Mth 11qW1kTSja3/RZJUsdkeueQWm6Ta6qkZdIefMAAGU6V+BPIhts2pjehbPcrr/vCxWpmCP/cHo+c71 UuJUB8vKjHvqJrf8vk67GcsAqfAym3bgnVbPbkcIg62rNwQKq6Obgf07d2l7Iok24LekYNGsCT1Co VizSxxULGtTgzzJOyOtR68csKejLdUc0VC79pyfajbs+k1DZ8L8/MZKkdPyeqVunWeDzIh8MXsGJm eJ9jcVHD2HntW8Y/mLvRZqOTM/3CVNctJVQILzS9e5xP56vFS48acD70JV5VDAbSgaQqKK6fee9x/ +iNzbDjw==; Received: from authenticated user by zero.zsh.org with local id 1o3NTc-000Fii-F2; Mon, 20 Jun 2022 19:54:24 +0000 Authentication-Results: zsh.org; iprev=pass (relay8-d.mail.gandi.net) smtp.remote-ip=217.70.183.201; dmarc=none header.from=chazelas.org; arc=none Received: from relay8-d.mail.gandi.net ([217.70.183.201]:54951) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1o3NTK-000FNO-Of; Mon, 20 Jun 2022 19:54:07 +0000 Received: (Authenticated sender: stephane@chazelas.org) by mail.gandi.net (Postfix) with ESMTPSA id A7CEB1BF204; Mon, 20 Jun 2022 19:54:05 +0000 (UTC) Date: Mon, 20 Jun 2022 20:54:04 +0100 From: Stephane Chazelas To: Paulo Diovani Cc: zsh-workers@zsh.org Subject: Re: [Bug] comparisson operator `[[` not working as expected Message-ID: <20220620195404.oamvev3ls6qnkpra@chazelas.org> Mail-Followup-To: Paulo Diovani , zsh-workers@zsh.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Seq: 50377 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: 2022-06-20 15:32:32 -0300, Paulo Diovani: [...] > In version 5.9 the [[ ]] operator is behaving unexpectedly for the > following case: > > $ watch ls & > $ [ $(jobs -l | wc -l) -gt 0 ] && echo jobs found || echo no jobs > jobs found > $ [[ $(jobs -l | wc -l) -gt 0 ]] && echo jobs found || echo no jobs > no jobs [...] While I agree that looks like a bug (the output of jobs seems to be empty when the command substitution is expanded inside [[...]] or ((...)) or a[$(jobs)]=... at least in my tests), a better approach here would be to use: if (( $#jobstates > 0 )); then echo jobs found else echo no jobs fi -- Stephane