From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 382302927C for ; Tue, 12 Mar 2024 21:49:15 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1710276555; b=Aksz0bTbXx+Bem471P6ROTybtdY3qBH+1p3Tpb4dHQoQWIGnfTkbPO5ZjGozarqaipFe1VzUTP DMCXo9YZgiV9a65WMtd6i3CfFylbTDIwiqbOqjfd/CBp31yGcd9ItSY/Ap+d04B8uGErwKYyOP AvU0fofeB9DmTgdt0/ykeoIbIVswzk0R+2Oun3mgpl4U/1JeLNlnRxysSUWkxN6Q8sc49eXcfV 15EoGBEuzyyNtvvN0mztf5Vdiq56kYptX25yLHnXbJDdCmr9LDoeSw2CjYlFBWGvM0poZ2q745 UyApqIbvVJJEwmzXKc34q662zwduw4Oiz9p6ZK4h0Hm47A==; 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=1710276555; bh=SQgfIAO3THVMO1IgAvoRyeon/7I8P628r2oRQ3gka6c=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature; b=GWiNaSB5WuDqunyXQXq9drTlTOhv8K6Qfx+ax58L8ZMG74UtTUYnDYPkqy+1LnVfQa6rWjajpb qZkyFXcqJer2wZ3Oov2df8HS6d13wvHagayQtOiV1DvRcH3ThMterzA6JQmnLxtsVcPDVaXJ5K FL9P3/uJ7dgwqqqXscYIfwU9XLkdau9jfT9latVC3kqtaEnZ7OS9pLYYlqjJ2FujxlAV7mgSZW YIbOWgMULtyOLLC87TNwwCJ1mdDR6tJVhAGYIlhc1VZa2a9M2sNRzolwkVG7QN/Wob0BWRC7cP YPr1RqJoc4HDD4TLV1ZchV6QjpFuEXRp8b5YgXlGsyjUjA==; 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-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=eCkh8vPPzjBckYEOSFmkb4LbTO7xh6CofQAfwpGQe80=; b=OiaA1i4IacWZVkQSOE6hXVWvAZ TE7CC0bt11PisoO/mrAFD/wKYopHt9mI4mqp2NWndVeNw72wNkF8MKOP1ZpJoMriOF6SdCo0HHjea 9AokG79BLRfc1/oRXXjoGTDmPYremG+K6fxzYG2x2UOtqw1VIWVKG9nqRR1hzVj8pIUyTtApxYwRv 8tZqwMXiM8/0ENraIH6yPODjQcbXXhNDgsO/TKM9jxL0/0alyBlSedfG7agHdSZ4EwxjF18qbt9lG gV7bE8/CDCEZgVv5SXxOqChowUe9Bsrg+ecc9HCO1k9aHzUOmBwSBAEV6MXp9P01hX6SRKIBqkOVI +dv63R9A==; Received: by zero.zsh.org with local id 1rk93j-0008Xu-72; Tue, 12 Mar 2024 20:49:15 +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]:59975) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1rk93S-0008D8-MN; Tue, 12 Mar 2024 20:48:59 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id D8E711BF203; Tue, 12 Mar 2024 20:48:57 +0000 (UTC) Date: Tue, 12 Mar 2024 20:48:57 +0000 From: Stephane Chazelas To: Bart Schaefer Cc: Zsh hackers list Subject: Re: "typeset -p" and no_GLOBAL_EXPORT, other misc. Message-ID: <20240312204857.fbwp6rgvp7kyuzmu@chazelas.org> Mail-Followup-To: Bart Schaefer , Zsh hackers list References: <20240312084926.d6vbk75ozud7i2jm@chazelas.org> <20240312200646.znbo4dw3rocza335@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-GND-Sasl: stephane@chazelas.org X-Seq: 52736 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: 2024-03-12 13:31:42 -0700, Bart Schaefer: > On Tue, Mar 12, 2024 at 1:06 PM Stephane Chazelas wrote: > > > > 2024-03-12 11:32:41 -0700, Bart Schaefer: > > > > > > Looks like "integer" et al. in bash actually search for the parameter > > > using the type [...] > > > > > > Does it always use outermost scope or does it just use the "nearest" > > > integer (in this example) that it finds? > > > > Sorry, you're missing my point. bash doesn't have an "integer" > > builtin. > > Fine, but my point was that the type and name are both used to search > for the parameter. If you instead wrote: > > $ f() { typeset -i i; integer i=2+2; echo "$i"; } > > Would that still find the global $i instead of "the $i in f"? My point was that the "typeset -gi i=2+2" that my integer function does affects the variable at the outer-most scope in bash, so typeset -g is not non-local-typeset there, but more like typeset-at-the-outermost-scope. Makes sense in that the "g" is meant for "global" and that "outermost scope" for a shell with dynamic scoping is likely the closest you can get to a "global" scope but in practice it's not useful because in a shell with dynamic scoping there's generally no good reason to want to single-out the outer-most scope as more special than any other scope in the call stack while there are often good reasons for "typeset" to just "set the type" of existing variable without instantiating a new variable in the current scope. Which is why I'm saying that bash's behaviour is undesirable and that we don't want to go there, and that zsh should carry on as it currently does in that regard (similar to what mksh and yash do, two other shells with dynamic scoping). > > > Aside: Shouldn't IGNORE_CLOSE_BRACES be set in ksh > > > emulation? It currently is not. > > > > I'd say > > > > $ zsh --emulate ksh -c 'echo go}' zsh:1: parse error near > > `}' $ zsh --emulate ksh -o ignoreclosebraces -c 'echo go}' > > go } > > Also beside the point, which is that the first of these three is wrong: > > % zsh --emulate ksh -c '{ echo go }' > go > % zsh --emulate ksh -o ignoreclosebraces -c '{ echo go }' > zsh:1: parse error near `}' > zsh --emulate ksh -o ignoreclosebraces -c '{ echo go; }' > go What I'm saying is that while ignoreclosebraces helps, it's not *enough* to give you ksh compatibility. AFAICT, to get ksh compatibility, } must be treated literally unless part of brace expansion {fd}> redirs, ${...} expansions. -- Stephane