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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20856 invoked from network); 18 Feb 2023 16:18:10 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 Feb 2023 16:18:10 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1676737090; b=ZwayYrOyoqmlZh/HZLs9xl3tswxoq40xtjYu3+bT3lD9sQ/BhfTLVfHbaM8pvZAtZyarFLHJzZ tF1tsKlftGRPRvE6X+ZDGEH2wH3CexBeCb1pYDGqyH/Kx5Aok1qyT3ZZuKximzjCB2uZei/U0G OvDakpJMM/k4qniAppGV8bEDyF2TBYGXsSsEKEGv6KAdqqzSQh7pVZ3B+7S+tbvOAh/VjtC2hb 8cv1jw+7LRico0nvRUpoU0fQtXy+X8CICN9eXqufRNVajHNDLvge7gEphaabw0rJSvDNEx3ys9 jUXXQYymN/Dmwfwo/ACrNpdyAs0KVib8Td5p5LprA0fnUw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f176.google.com) smtp.remote-ip=209.85.208.176; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1676737090; bh=dOqjEEDz2T0DjDhhHh4vREpZAFaCthwXhogSRe9Y4qk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=YN8iV3Q5iQxQf/V2pQSJOMfdEGmZa033SPrMmsl4D10ufnm6MtdSBrzsGxsY1ghbu9ZX1VmSrW 2vOMUwfOZjdvHe383i45w+rBaukHLrV3KyeWJSmXZAllhTm2DQiMmGFcLWSi3vDj+UIv84zYWr 3H0l+MWes/RL7HeUOYqR0+0vr6g9qrt0l7STuCqL2e18WqSej8p/Uat7HerUsJYMSC2dzaL4fC D++xnUBj01DvLPg1ioK/r57VCb+XDb5eO45n6IghIz7UqSld29ra0WEAP6YpWJYGUBwCA/cGrv RnOagRJVxg1YC0OgiThhdyGbFW74PgHQdUzSTWunGszonA==; 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:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References: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=SEVry8ensuEEQ2MO9BhaU2P4pxykfZM04RI+1aF7tmQ=; b=l3IR2m83gdhJJYO8vFjGVFOff0 bEd+03hxNiJ2bZgARIIOqSQeixKKtBGTR3E0zURDKIARM8xTNh/zbfHLc/8empQUJYXuj0BH/k9SG BmCmPSCivxlT80u+IplPsEpgX9U54j5sX+8iHkH4bTaxhn31cY1SPM2Gpn1FZo3C9P95eN6xZQU67 seSkQX6zIcTK8YkuQE0wl7q724JqjCZNr5qszM42yl5P5AYfjF2JiYQ7nk7zkBmWIgM/9TzxQHaN9 qvDVAoJDrlAfJ/4wVTp3cYFLxzv4LSSe9XnHuLRYjmfYedBDR020/zsJWJX8YWvlq/Em3XUfkGeYG r6VBIr/A==; Received: by zero.zsh.org with local id 1pTPub-000Eop-CD; Sat, 18 Feb 2023 16:18:09 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f176.google.com) smtp.remote-ip=209.85.208.176; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f176.google.com ([209.85.208.176]:45036) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pTPu3-000EVe-16; Sat, 18 Feb 2023 16:17:35 +0000 Received: by mail-lj1-f176.google.com with SMTP id r10so1078853ljd.11 for ; Sat, 18 Feb 2023 08:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SEVry8ensuEEQ2MO9BhaU2P4pxykfZM04RI+1aF7tmQ=; b=GhnzPDva03umP7SY7qj2RzyDpPfhvDaA1qOG3giSOnewfAn6I3agLvXhiPE8RFJ8DU LObOnz8TxLLxdhAWsNT+Zr6sC5N6o2zvbHcOeM5SvEKvWPCWDMaqy7Plh9dWrYwLuC3v BfJ+wjcdfsHBCQc7GSUHBcWS50yKjL0i9beb66x9UKB/r59tNlbGxWLETUAI5Ep0x0P7 7JI/nVFNGbYTI2BkOzVl15iwbF6yRrL5esv/i+t9GnT8jBYW1ughfo4d8CSUxce3lyZ5 USh5hexz7rInwHGv6pDuERoqhWb/o3F2ZTyHhZlZTbiqvYhaWbqPZXeJHVwenXtuGw92 Xf4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc: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=SEVry8ensuEEQ2MO9BhaU2P4pxykfZM04RI+1aF7tmQ=; b=U2ScYy/kciEtLfEUtCEFf2L1EEKIIKEm1EyT3RaomXvdgQ0GveWs6XVndHJRVeB1GZ ZBY3cW8Eou1l2kjRo6d2A9mMkD702+zoRdYSmL4aJI6DoXYUhlmBDS78vAfzbwpIBA0z +y8+dRXe3nxzIqnoIiLs40YVhvQliAhuLOyVVXFBlJWHnPL2S78S8eR6tRqh2bsXkmIK iI+BAp6fDmMorleNWtd8ZKRZ5nIO/ra9R2gPN4LdP8yHfPTVZgGkZ4s982xj7BfS1ToT EYOyJZQkxrbCj+TXbzdRHmE5c803zM6X60kq97Aul+Dp/ekLRQgCd61+axfUvVsk0kX3 0zZQ== X-Gm-Message-State: AO0yUKWU5ZHeVi9HYFx0SymXpG3e18gPot0xtVkKUI/R/IfE1Cs0g4x3 Q50o97yrujUgpzwktj4OefOkTKoz1fOskWcMDj4Jiut3 X-Google-Smtp-Source: AK7set/L8vDxsmGmMpez1FuXjnIgiACsnKKOEjeIA0pf2iEM7XhZlMgK9hMvewTWtZ2W1cwVXO711OKLly0n/cdbZ44= X-Received: by 2002:a2e:b988:0:b0:293:261e:74ce with SMTP id p8-20020a2eb988000000b00293261e74cemr1339330ljp.4.1676737054230; Sat, 18 Feb 2023 08:17:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Sat, 18 Feb 2023 17:17:21 +0100 Message-ID: Subject: Re: Is there a way to set a var above it's current scope? To: Roman Perepelitsa Cc: Zsh hackers list Content-Type: multipart/alternative; boundary="0000000000007fcb6405f4fbc4cb" X-Seq: 51459 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: --0000000000007fcb6405f4fbc4cb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yes I know, also one can use local at global scope to have the same effect as typeset -g there, this is a direct effect of how scopes are implemented. sob., 18 lut 2023, 16:30 u=C5=BCytkownik Roman Perepelitsa < roman.perepelitsa@gmail.com> napisa=C5=82: > On Sat, Feb 18, 2023 at 3:57 PM Sebastian Gniazdowski > wrote: > > > > Somewhere in the man I saw something like: if you use export you'll > > always set in global scope, regardless of any local variable > > collision. > > You might be confusing it with the fact that `typeset -x q` is > equivalent to `typeset -gx q` and `export q` when used within a > function, even though normally `typeset` within a function is > equivalent to `local`. > > > Is there any way of achieving this? > > If there is a variable in function scope, there is no way to do > anything with the identically-named variable in global scope. > > q=3D42 > > () { > local q; > # Nothing you can do here will have any > # effect on the global `q`. > } > > Roman. > --0000000000007fcb6405f4fbc4cb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Yes I know, also one can use local at global scope to hav= e the same effect as typeset -g there, this is a direct effect of how scope= s are implemented.

sob., 18 lut 2023, 16:30 u=C5=BCytkownik Roman Perepelits= a <roman.perepelitsa@gmai= l.com> napisa=C5=82:
On Sat,= Feb 18, 2023 at 3:57 PM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Somewhere in the man I saw something like: if you use export you'l= l
> always set in global scope, regardless of any local variable
> collision.

You might be confusing it with the fact that `typeset -x q` is
equivalent to `typeset -gx q` and `export q` when used within a
function, even though normally `typeset` within a function is
equivalent to `local`.

> Is there any way of achieving this?

If there is a variable in function scope, there is no way to do
anything with the identically-named variable in global scope.

=C2=A0 =C2=A0 q=3D42

=C2=A0 =C2=A0 () {
=C2=A0 =C2=A0 =C2=A0 local q;
=C2=A0 =C2=A0 =C2=A0 # Nothing you can do here will have any
=C2=A0 =C2=A0 =C2=A0 # effect on the global `q`.
=C2=A0 =C2=A0 }

Roman.
--0000000000007fcb6405f4fbc4cb--