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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11134 invoked from network); 20 Aug 2022 00:45:47 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Aug 2022 00:45:47 -0000 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-Type:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6f17ki/NBKTV/zSUh6vAtRRaGz6z6U6ObV1JPRGwJ6g=; b=pseUFmoD5w4xPvZwj5/L9jDylL /QVxYNW9HQrRc/bGEOivZX6t/mz1eb6NlgfpKotAQtjo9cPRi587TkxhaMNwfUyJjfGdFTIee4GSL cbQiiQ8HimKLJmhJnyqLKg0ZeNKRE8PtM3wYE/pyE2fQr3XokNa2UgoWo1CzJZTd6HiaZ8xCybfAx 9afPi1jEcio7uElpqd56V1bySIPTN3BF88gMDhXbQ2pcx8ZvSeG+0OEJ/2u7woqSOxUsZuGgd3eqx IbPPwlKTrlFLQe13v5UXvO1JergkcHLUEJS8Fk/l+UdNdJtNlLoCKYajb4iY0av2qfzN0G2Vk7m4a +elP6oVA==; Received: from authenticated user by zero.zsh.org with local id 1oPCcU-000Llk-2g; Sat, 20 Aug 2022 00:45:46 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oPCXK-000LJM-Uu; Sat, 20 Aug 2022 00:40:27 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 3034027C0054; Fri, 19 Aug 2022 20:40:22 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Fri, 19 Aug 2022 20:40:22 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdeivddgfeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvvefutgesth dtredtreerjeenucfhrhhomhepnfgrfihrvghntggvpgggvghljoiiqhhuvgiiuceolhgr rhhrhihvseiishhhrdhorhhgqeenucggtffrrghtthgvrhhnpeehfffhueejheeugffgfe euudffledvleegffeuhedvveekueegiedugfelueefteenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehlrghrrhihvhdomhgvshhmthhprghuth hhphgvrhhsohhnrghlihhthidqudduhedukeejjedtgedqudduledvjeefkeehqdhlrghr rhihvheppeiishhhrdhorhhgsehfrghsthhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id E8D9D31A0062; Fri, 19 Aug 2022 20:40:21 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-841-g7899e99a45-fm-20220811.002-g7899e99a Mime-Version: 1.0 Message-Id: <605183ae-f347-4f64-bf99-e89f98b6637e@www.fastmail.com> In-Reply-To: References: Date: Fri, 19 Aug 2022 20:39:53 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Liu Xin" Cc: zsh-workers@zsh.org Subject: Re: An incompatible behavior from bash? Content-Type: text/plain X-Seq: 50489 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: On Fri, Aug 19, 2022, at 6:32 PM, Liu Xin wrote: > I think zsh is compatible with bash It is only partially compatible, and compatibility is not a development priority. The notion that zsh is a fancy superset of bash is false; zsh will only run simple bash scripts correctly. (Whether it errs loudly or quietly depends on the feature used. Using sh emulation may also help.) You are better off assuming that an arbitrary bash feature *does not* work with zsh unless proven otherwise, rather than assuming that it *does* work. > but I found one different behavior > in parameter expansion. In the following example, I guess zsh > interprets "$1:l" as a whole. Is it intentional? Yes. From the documentation you linked: In addition to the following operations, the colon modifiers described in "Modifiers" in "History Expansion" can be applied: for example, ${i:s/foo/bar/} performs string substitution on the expansion of parameter $i. [...] ${name} The value, if any, of the parameter _name_ is substituted. [...] In addition, more complicated forms of substitution usually require the braces to be present; exceptions, which only apply if the option KSH_ARRAYS is not set, are a single subscript or any colon modifiers appearing after the name [...]. Your example applies the "l" history modifier, which converts the expansion to lowercase. This is more obvious with a different choice of value: % export VAR=HELLO % zsh -c 'echo "$VAR:l"' hello Braces are required if KSH_ARRAYS is set (either explicitly or via sh/ksh emulation). % zsh --emulate sh -c 'echo "$VAR:l"' HELLO:l % zsh --emulate sh -c 'echo "${VAR:l}"' hello -- vq