Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBB32C433FE for ; Tue, 19 Oct 2021 11:05:21 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AA829604DB for ; Tue, 19 Oct 2021 11:05:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AA829604DB Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=xenproject.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.213002.371081 (Exim 4.92) (envelope-from ) id 1mcmvX-0005XR-BD; Tue, 19 Oct 2021 11:05:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 213002.371081; Tue, 19 Oct 2021 11:05:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmvX-0005XK-7x; Tue, 19 Oct 2021 11:05:03 +0000 Received: by outflank-mailman (input) for mailman id 213002; Tue, 19 Oct 2021 11:05:01 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmvV-0005XE-KW for xen-devel@lists.xenproject.org; Tue, 19 Oct 2021 11:05:01 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mcmvV-0008AP-Iv for xen-devel@lists.xenproject.org; Tue, 19 Oct 2021 11:05:01 +0000 Received: from iwj (helo=mariner.uk.xensource.com) by xenbits.xenproject.org with local-bsmtp (Exim 4.92) (envelope-from ) id 1mcmvV-0004qB-Hn for xen-devel@lists.xenproject.org; Tue, 19 Oct 2021 11:05:01 +0000 Received: from iwj by mariner.uk.xensource.com with local (Exim 4.89) (envelope-from ) id 1mcmvP-0000FM-0D; Tue, 19 Oct 2021 12:04:55 +0100 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=References:In-Reply-To:Subject:Cc:To:Date :Message-ID:Content-Transfer-Encoding:Content-Type:MIME-Version:From; bh=nnb2geRbcbSlLgx5UdzGDOidH9vfIgTEmDTEzYRrLh4=; b=bFWHsskyJYCiklS6BHMq8i+lxK s1HwetjJbecHc0QGHkoHb1hhkTRuTY9wUek4kvIdUP4IOMVG8vd6ShWmUzOzmhlIWo/6E5pXnfUFi Q1/st3Bp6SBkw2qNUN5FiKlIUNpm2gSOqrBgbsZubGkT93N0Y5sc0NvSUm3Tx0ozo3AQ=; From: Ian Jackson MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <24942.42582.584340.453247@mariner.uk.xensource.com> Date: Tue, 19 Oct 2021 12:04:54 +0100 To: Jan Beulich Cc: Juergen Gross , Wei Liu , xen-devel@lists.xenproject.org Subject: Re: [PATCH] tools: fix oom setting of xenstored In-Reply-To: <912b03a3-90df-e94e-77a9-5c673acfef04@suse.com> References: <20211019044123.29648-1-jgross@suse.com> <0c93abe3-3908-009f-efca-08000092cd4d@suse.com> <912b03a3-90df-e94e-77a9-5c673acfef04@suse.com> X-Mailer: VM 8.2.0b under 24.5.1 (i686-pc-linux-gnu) Jan Beulich writes ("Re: [PATCH] tools: fix oom setting of xenstored"): > On 19.10.2021 09:31, Juergen Gross wrote: > > I don't think set -e would have a negative effect on above line. The > > bash man-page tells me that: > > > > The shell does not exit if the command that fails is part of the > > command list immediately following a while or until keyword, part of > > the test following the if, ... > > > > And I believe that "[ ... ]" is treated like an "if". > > I don't think so - "[ ... ]" is an equivalent of "test ...", i.e. > unrelated to whether that's an operand of "if". The question is > what effect && has, i.e. the behavior is due to what you've > hidden by using ... in your quotation: "..., and is not a part of > an AND or OR list, ...". "[ ... ]" is precisely equivalent to "test ...". But neither of these is eqivalent to an "if". When the docs say "part of the test following the if" they are using the word "test" informally. > I think I recall constructs like the one you use not working with > "set -e" on at least some bash versions, though. Apparently this > was due to a bash bug then (or I'm misremembering, but that's not > overly likely since some of my long used scripts specifically > avoid using && in such situations). I agree that we should avoid this && construct. Can we not just use conditional assignment of a default value or an if statement ? > > ( set -e; [ -z "" ] && xx=okay; echo $xx; ) > > > > This will print "okay", so bash didn't exit. > > Of course, because the left side of && succeeds. You'd need > > ( set -e; [ -z "xxx" ] && xx=okay; echo xx=$xx; ) > > and observe "xx=" getting printed. Which indeed I do observe on > the one bash version I've tried to double check. But that one's > surely newer than what I think I saw such problems on. I think this particular && and || usage is not an idiomatic way of spelling what would normally be a conditional in shell. I think try_this || try_that is fine but variable_nonempty || variable=value is strange. I would use ${param:=default_setting} or ${param:-default} (or perhaps the colon-less variants). Ian.