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 6978 invoked from network); 22 Jan 2023 09:35:30 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Jan 2023 09:35:30 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674380130; b=qtWSakb7xraxTrJP5EUCevf5Rbc3z3P50CHzwsfpN5ATlUXoKAipqqJnT07f30e2QXOHedBtnW AjLex3qSkJFFFZOyMJmSBS0LZRrBOzr8NHBctJLTMVDxCEB2b2Z7wkJPjYt8E5GkZ3J8wFTj9z BX+LkNvJPZkukAalnzTWro4IG4jFKqOZTVNvhJ/+Vwus92YIVxkIiiEFogTgt18/ivnb/mpX05 2CD+DRrXB4gxquoBWobTxXet61DnoHazqOJ9YStndtt4Weh5dZ2ENhy4DYNIAbPdmHfpdLsbRV dW3l7Qw5roXhfPppxuf0TNFKqiHnHkVnZ7MT4lzDeO5h3g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; 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=1674380130; bh=f/Dr+/ZfpI4smhZFsflrsuNrH+zEvxCs0heDf5Cshek=; 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=p5f6TtsLM/OWDneW9z0VFtUoJVsOLtwk2iuvWycLSqKiZ9QkDst72Fy+xup6Vncyy1zBqsUs7S i3W6jXftQCE/jHTzcjF735X2KoIO+eHeB9yUPJyYMBLlv5WZZGnZytkfNen9o4Tksx72q+MoYv GDSKLN9/jwMrZ9YjPzFKlGgvKMYFeVAt2flpXTBBHxBOEBHPWX6AmmdF2qmiDlj9Y4Rw+PiXUO D5LFab8DTdh/kM+1ByLJaprD8CzLNaA7kzJvnLmm3x5Z3iyEJvMR5n2+2VjoOYIRoTaAXEqtAd C4/3sJreg0d6as7WvsjenPXs0vTqqf8tlwUai+2Ay2b2rg==; 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=ZuCLMXvci6NpyIh8kiYwU/ejn9EHi1iqevz7Ve69U3E=; b=TVMKq5ptgtLvJ8VgXrJB5oSn// 2i9y/sAUYFFyPKshSeT+uNN1c9hXiktSJz3xp6Tv+R/mek5VC/pT0HNwl69JUqISFfYAiKdkLOmt2 tGe/UHZpg28B3xabQZnvctemPgf/Ej/PxozpFUbbnP8ehXS0jygqp+k4x3yxaItUdgtqFr2wS2YVf lcA9QzJaejTSW+CSZwI0QFTbY2kEAbuZDDqFblkNhZyEvtWCLkGfXAhXiy33jTCp/uv4OdGc6ogJc egcvfgbjN3b07ZB9E5brKC2V8C8TCv8OlaLb1GqQGX0gCdSU+HM0aVdhfQzCsrmMUVuf6qo9QeH1W taSec8iQ==; Received: by zero.zsh.org with local id 1pJWl6-000IIG-So; Sun, 22 Jan 2023 09:35:28 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f42.google.com) smtp.remote-ip=209.85.218.42; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f42.google.com ([209.85.218.42]:44619) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pJWkD-000HZ3-Eo; Sun, 22 Jan 2023 09:34:34 +0000 Received: by mail-ej1-f42.google.com with SMTP id ss4so23653605ejb.11 for ; Sun, 22 Jan 2023 01:34:33 -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=ZuCLMXvci6NpyIh8kiYwU/ejn9EHi1iqevz7Ve69U3E=; b=C+gfM2i5fjkZLcEQaXpFVdRjOTCaLt9taLlj0bHtjlBxRe/F+zS0pVJTuf03kUfHZu M9H+0ytXHfKo6lksi2b+oRkj1N2U0FrdOH5C1Gogostm4Hy4lwoi3FWFyTtJpvu8xFAx 7BsIpETZer9NAawzjJe2/aNyM/qyHeuAFrkzWWzRjRv+BFqkc6BsQ1i0VP57Jekhcqbh NtgpwZWhreoLrCqOvFytpRR2ZHJx5OMe5EienlmgQRJZ7WcRr2qwHUDqOr2QAPXFNyrX eTFWhShNBv4zula78uZNML9Nv/zUI2YHiYMJuJeSDYQpzUvHFMsUQSmA0hRP7l7wVKry ZCvw== 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=ZuCLMXvci6NpyIh8kiYwU/ejn9EHi1iqevz7Ve69U3E=; b=rSSIyk9s857edJjz39QtD4rRuYpSvu8m2stxxD9vU1csq9h2+0YlujKzCX4Z8d0e8N Vf5Z2vZO/8g37uiKnRmbdB7aOqwKtebJMcEzj+KXpl9sTm31xWON0p8g6/DZTUFwi5tB COyGEmPfQRqlH+ihEqKBbT0+igsSnoCWngTuHzFjs+CqrzKwpJ0n8FpPmYBlm6elE/EU 9fs/VZTCjyGRe/oqxSUKRrpWkE/t6rr6Ba9VY0JvgGYrRp6AjKJIevR0fVJOeiw6QktA grDpmqMFJxNOtNRiORqc/rTPCsRbAioa2qx0w30LnDDlCsOC5s6jeclyi/rFHKblwUSg IA9Q== X-Gm-Message-State: AFqh2koEfxa7D9xuOwshn/+2cPyaNSBJPg0nSH4VvIn9frNQi3hmu/BJ BP6drsWoELrVfSBU5Xz8fbzBXFc6mUXR9woBgfo= X-Google-Smtp-Source: AMrXdXtVDOvTCuAtYuvIvqSrQjnz9j8LX23SXD5oU5fJVjUb2BKwm6P7Tzr73DCj4AswRQ6K/9hsulAmVvMGAeH7qQo= X-Received: by 2002:a17:906:7e4f:b0:872:3170:c381 with SMTP id z15-20020a1709067e4f00b008723170c381mr1659225ejr.90.1674380072305; Sun, 22 Jan 2023 01:34:32 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pier Paolo Grassi Date: Sun, 22 Jan 2023 10:34:21 +0100 Message-ID: Subject: Re: A way to untie -T vars? To: Roman Perepelitsa Cc: Bart Schaefer , Zsh Users Content-Type: multipart/alternative; boundary="0000000000006dc88905f2d6fd79" X-Seq: 28708 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --0000000000006dc88905f2d6fd79 Content-Type: text/plain; charset="UTF-8" and what your solution could look like? I would use something like ___untie_array and ___untie_scalar that I would never use outside the untie function, but I wonder if there is a more general solution Il giorno sab 21 gen 2023 alle 20:16 Roman Perepelitsa < roman.perepelitsa@gmail.com> ha scritto: > On Sat, Jan 21, 2023 at 7:53 PM Bart Schaefer > wrote: > > > > Speaking of unorthodoxy ... > > > > untie () { > > emulate -L zsh > > case ${(tP)1} in > > (scalar-tied) > > local scalar=${(P)1} > > unset $1 > > typeset -g $1=$scalar > > ;; > > (array-tied) > > local array=( ${(P)1} ) > > unset $1 > > # Need eval here for array assignment, as > > # reserved word doesn't work with $1=(...) > > eval "typeset -ga $1=( \$array )" > > ;; > > (*) ;; > > esac > > } > > Bravo. > > `untie scalar` and `untie array` won't work due to name clashes but > this seems easily fixable. > > Roman. > > -- Pier Paolo Grassi --0000000000006dc88905f2d6fd79 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
and what your solution could look like? I would use somet= hing like ___untie_array and ___untie_scalar that I would never use outside= the untie function, but I wonder if there is a more general solution
=

I= l giorno sab 21 gen 2023 alle 20:16 Roman Perepelitsa <roman.perepelitsa@gmail.com> ha scritt= o:
On Sat, Jan 21, 2023 at 7:53 PM = Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> Speaking of unorthodoxy ...
>
> untie () {
>=C2=A0 =C2=A0emulate -L zsh
>=C2=A0 =C2=A0case ${(tP)1} in
>=C2=A0 =C2=A0(scalar-tied)
>=C2=A0 =C2=A0 =C2=A0local scalar=3D${(P)1}
>=C2=A0 =C2=A0 =C2=A0unset $1
>=C2=A0 =C2=A0 =C2=A0typeset -g $1=3D$scalar
>=C2=A0 =C2=A0 =C2=A0;;
>=C2=A0 =C2=A0(array-tied)
>=C2=A0 =C2=A0 =C2=A0local array=3D( ${(P)1} )
>=C2=A0 =C2=A0 =C2=A0unset $1
>=C2=A0 =C2=A0 =C2=A0# Need eval here for array assignment, as
>=C2=A0 =C2=A0 =C2=A0# reserved word doesn't work with $1=3D(...) >=C2=A0 =C2=A0 =C2=A0eval "typeset -ga $1=3D( \$array )"
>=C2=A0 =C2=A0 =C2=A0;;
>=C2=A0 =C2=A0(*) ;;
>=C2=A0 =C2=A0esac
> }

Bravo.

`untie scalar` and `untie array` won't work due to name clashes but
this seems easily fixable.

Roman.

--
Pier Paolo Grassi
--0000000000006dc88905f2d6fd79--