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 B50CC2C6D4 for ; Tue, 12 Mar 2024 19:33:13 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1710268393; b=ZtUVbOsXujZiATtkqb8EBAloJHD6xl+rqgwTxt6u2GIBvw05bwVbHLWOKM5xTRQ6yOvEG+yh4D 4RHDUusDz+OZXaYhKcQABvowKlnIa+x7TguaUhSYAGfW46/AqYNE8l8dvT8hu1+KB7fkv5uJbf PS9G0/WxazOwg59Nrn8TnXY6H01GALQ0HLFrDv+cSXmjOE+4cKxZkJWypeHaxYWiG7OpmKolr6 Ve8lU5L5p+FWNioAjZppI5OV6rDxNXmdtI0jHF+bvFyTjxISAcO6DZm5QK10FvQEZkzBsOpomu m1j+VRzw6Q394nplejbztYX5txaJSGS/mo7XUe02qdYv1g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f41.google.com) smtp.remote-ip=209.85.218.41; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1710268393; bh=gMCXVX0JbAjuIspDEJiLkzlcWxeW0UW+lqr1x81zRCw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature:DKIM-Signature; b=prh609uM8wlJWLVPK7LnqiHZ+ZShwKD15lZ2PNwNzdrJtGnDPUUQNV3Q0jRrYgAUrVIheOekiR 5NtZ3AdHWbkhgsBD4jGPqiUscMCHvmNjd2b+BkvM3xxRtLNR9qadwEaS47hPgzoezpdzWWKfnB QQaIxtDvT0Q6bprvbFhaunUIPH5ZB34o6haqm4zkTkuxnhfSiHZcG64bniGmNdA4Gdx5peC65S eHMEwVgC6ZNNeE1Ak+vwKY15XlLaoRR+BwKLVmz2dbxTGXdN7N6qAxrHxS8yapEHxKCpqZ8Ixk cjtWGeWtSwU7ZPAG9nEupa3WUT6iaelrilqPaIgD8OaJdQ==; 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:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=ouX9n+5lIVrvOepbtxzz1VgH8qCX6JnCgJQhekLk4Cs=; b=RPMt71bT5Mx7nIrq93uabDcop9 sPW9pZde/AKs1ag3BHWL1NaYw8by7fPFSGlO+XusuWiJCy5R516dtelbLx+aqAekIut9rBq2IaS8a TcbweA0hCWIKJTslVU/TJdIZslIqAKGwlmfk95qXS6vnip/fdfo3FGowMbJy9jOlYjJNeXYeJj0RO eNOfXh427FkcsrxfPijqTxajjsixlDR3u1QVxQP7X4vs3MT/cKaobkhm2Oar06iBFiObWZKnIF2eR 3Vs6Q3sGa6gQr8DODLvEfYhqSG7Z66vC3odXYERo7RWAazf7ESvtd5OvG++U9BRbyKuIX4jT60/a+ DLMvthoQ==; Received: by zero.zsh.org with local id 1rk6w5-0000n4-68; Tue, 12 Mar 2024 18:33:13 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f41.google.com) smtp.remote-ip=209.85.218.41; dkim=pass header.d=brasslantern-com.20230601.gappssmtp.com header.s=20230601 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f41.google.com ([209.85.218.41]:54619) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1rk6vm-0000SA-H4; Tue, 12 Mar 2024 18:32:56 +0000 Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a44e3176120so759994366b.1 for ; Tue, 12 Mar 2024 11:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20230601.gappssmtp.com; s=20230601; t=1710268374; x=1710873174; darn=zsh.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ouX9n+5lIVrvOepbtxzz1VgH8qCX6JnCgJQhekLk4Cs=; b=phWOywDBzJp2sUbfMJ/SUMpaNZ6ET9CeTeg75kwpn1uKTswnPhbLj5qTJtIv/GcCIA odBrGV6jdMZULGJqXU1ihayA7R5Uw3EkFyVJgUlWAh63iHl133dqrS+FWMq+AZgyC7Sx BIsM52XTYTBRjDhsh+MCkDux9tGRPxRyhP6JGs5TrmFZvJkpShLuIhFHgEk4wodZhhKU YWspU1GK1a/x9VWTLtP9QJ0jeVt+dpJ3e64FE7LltFgCB6OHqWe0FHvdYLY98jpq1BXX /mztG2ZrBj++oaMajUfTdKzey+csfep4sg2T1rZM3fRPKRdrJwPWfFjzq40IsTYUhmNY mFsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268374; x=1710873174; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ouX9n+5lIVrvOepbtxzz1VgH8qCX6JnCgJQhekLk4Cs=; b=S+xoqzV6yitlr/zRMtbrol+fk+/vEz52P56MYajZO//aEqQYzE3N7egYbq7xRGQ4tm G23DihIXOL2kSXjWsZ0A+96pCbeTVOiWm7Rl3qBKWCQ2nEsiv2E8r6UT5cUadg32guGH xrJP76knMFC5W33VJaoRnoZwaq0CgrO2sTffTzlNfs7DFJLxMWsL/48LcpWLNj63ZccX JUJl3epWaiIgttpVm6sAUsXXoToLgEUJLBppziVQJkYpieNTyvNaVe5wBDmCfV12Vh9r UQvALslI8Rl2ISAI90NxTHfb2ga2HDO1qDksq2HgjB2wegEs1mHiC/7rZfKg3eL3qedJ pspQ== X-Gm-Message-State: AOJu0YwEiyKnwTSXig0r6zgAuBgYNFXThbAfdbpnisvnqX/YCJK2Gr+Z bPC0R11zFF9c45/LmjWHZBybAOrmRB25j99l+XMofLaD9m6l+BntNqet5JsqFqpOYPsg+pWuWLL E8wqUatgwwChafbT03wMA+ydi4/KV1gaLow9LS/Ph2ZjR4qPXEg== X-Google-Smtp-Source: AGHT+IFCD8u8u2Izeb1MamEBJhSzk7dzX9SiKP1LmkLz0MEjzTD2Yifu97EPBGNkLt3KGsnY/ixmvilEp/afrKaKf9g= X-Received: by 2002:a17:907:d509:b0:a44:e2e0:bda8 with SMTP id wb9-20020a170907d50900b00a44e2e0bda8mr9150320ejc.0.1710268373864; Tue, 12 Mar 2024 11:32:53 -0700 (PDT) MIME-Version: 1.0 References: <20240312084926.d6vbk75ozud7i2jm@chazelas.org> In-Reply-To: <20240312084926.d6vbk75ozud7i2jm@chazelas.org> From: Bart Schaefer Date: Tue, 12 Mar 2024 11:32:41 -0700 Message-ID: Subject: Re: "typeset -p" and no_GLOBAL_EXPORT, other misc. To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 52731 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 Tue, Mar 12, 2024 at 1:49=E2=80=AFAM Stephane Chazelas wrote: > > IMO, typeset -g should only mean: don't make it local, do not > instantiate a new variable in the current scope. As I think I mentioned elsewhere, zsh's "typeset -g" (in the absence of -p) only applies to newly instantiated parameters -- it will still find parameters in the current (or enclosing) scope if they already exist. Which typically means it creates a parameter in the outermost scope, but I suppose also answers some of my other questions, e.g., +p -g should still find everything including locals and is not necessarily equivalent to -p +g. > bash-5.3$ f() { local i; integer i=3D2+2; echo "$i"; } > bash-5.3$ f > > bash-5.3$ echo $i > 4 > > That "integer" changed the type of the global (outer-most) i > variable instead of that of its caller. Looks like "integer" et al. in bash actually search for the parameter using the type (which corresponds to what zsh attempts to do when using -p), rather searching for the parameter name and then altering the type (which zsh without my patch sometimes does by accident). Does it always use outermost scope or does it just use the "nearest" integer (in this example) that it finds? > In zsh, readonly var, when not emulating other shells is more > like typeset -r: It should in fact be exactly like "typeset -r", and export should be exactly like "typeset +x". > ksh93 does static scoping As someone else pointed out elsewhere, this depends on whether you do foo() { ...; } or function foo { ...; } but really, I don't care, as we don't emulate this bit anyway. Aside: Shouldn't IGNORE_CLOSE_BRACES be set in ksh emulation? It currently is not.