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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3886 invoked from network); 21 Jan 2023 18:53:09 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 21 Jan 2023 18:53:09 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674327189; b=TOA2RQL4AAohAexkQ65bFhR+Wcd7JmVJSMfGC7Nssh1RHF9vZS0J/4dtHPYaBmMaElVuVkn9wO ApCQOT/L2elgmtkPTHlllke4/4sma7edtYVpuuT+XzCqeTszH63cVL98YfIRAtg4zKicRvS4+9 MVTPugxkB/Y46rOLO66NEQU2xs1tt6KZzDw8NlnPxE7tILQFYByun/kIUkZrZkSqZiRuDi7Vzy LBn35h3qaP/pdS6vc40LKwflAx6CvVljoETbsW59zkCw5eMIUfTUDHJjrWFgggCpngcMBS7PVA 54TDlaCkKo/95mDfim1mzIBJcothy0JWMfwZcA9NRjHdHA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 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=1674327189; bh=hMT4KieOUnNOnGXzP2o6elazy2wNE7NyzyLSoxdrY2M=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=r67Bb7g2wzZqYdde3Mbp0fVy3h9HqQy9a3O7R1i1Ye7ZoL8GGvp7LUipT17kgiirLP3oN77wxD n17APo65eyUUQeUnbTt2kYcxhPENKl6GbQQv1thSXeXgaPs/Kyax6jVZCHLY2an8SV1uXPB9zW dUt8lkalihTKWzkPv+8+7kbx2qSrlaWszbuV3cqXhVRwwL6t25lhKnVmdchOd8juIzMI+qvM3B RwPVcZC5PUWKZHg+jnS017mH+BPrTNfEdXPdoo1PYQgBjaMOUQAidosoXwy/wpXSIRRh7NcF8s MVlFtihDym4/T2eLRBA5SDEzmCJHBUegZ3fWNhH2kAosRw==; 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:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=+5+lKxLzyQOE7szGuIq69L0G6aas0uetR5LUwRLLdVY=; b=fB2lSsBmgqi8PHgbdI/96c1V/5 0TTfkQSXtJPOcNSCWTUz75WXe3cgVmsDNeqNqPENQaniIKaNY3v7YLkkT5Ct/1WieTkFOdTyhE9lW v8tR0B+6avKwNRmajepIVQZeMfSsOvN9PswQ3dmM9agBVBZCihSc8APNL211rNEGxgRZogFW+hsDI 1vMkQSKNILVM+Z3gzWc0YG/U8s5TsOBAhpNzEBQvfKQ8VpFMss+B39tBZKM8LoBJIpCPVb6HSI5cY SOydkrfggSc8jMUr3/RcicO2XuiSM4gvjbsjNOmg3uic7C8SILzkiR4Sr60t3DDFx9+U5N5N1dc0E 0xXNVDZQ==; Received: by zero.zsh.org with local id 1pJIzE-0009IN-IV; Sat, 21 Jan 2023 18:53:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f46.google.com) smtp.remote-ip=209.85.218.46; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f46.google.com ([209.85.218.46]:46059) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pJIyY-0008Zh-U4; Sat, 21 Jan 2023 18:52:28 +0000 Received: by mail-ej1-f46.google.com with SMTP id vw16so21476063ejc.12 for ; Sat, 21 Jan 2023 10:52:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=+5+lKxLzyQOE7szGuIq69L0G6aas0uetR5LUwRLLdVY=; b=VKbcTGuCKltSfBNJV/dDDYfCkn+HL08T6NwQPWm6Xun7jnUTyoZ2QPcN/uAtkZZ6Qr VTvzlR3SdaDM54G3367OtBO4Xa8yIEPTMvle+bVfno62ei+LwA84ubHplzle2BCKEzbL ygr2nFXFQ7z8TRzt7cXwpifk/HxdBxSyN24/I1SofI2TytgR2aP5GDFnvMqGeO8fgwGm 4/5SwHdz1IkT8P0egS8Kr8whYnmO1IQ/zK2eZwB8STZsLoCoPXaq2T7A0J7pnAkFykuO OGVF7eARFLWeYww2044gTCyFlIeDAn3KNOlGZxbVqG+xDQI+ptjzJSp5n4qe3wVK5TL0 aYXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=+5+lKxLzyQOE7szGuIq69L0G6aas0uetR5LUwRLLdVY=; b=o++5nnGMbkbvaTfT2WLK/L1fB6KwYz+ohrBAExy7KWoxdcZXT7ADcTPPuFGFik5vJu 93fCg2G8cVo+nlKSYbaNgVoQGwQaLF7SDkmxqa76z6ugr22ukNUB6dy+GGtDKYeBydls qAMcy02EEKrtGtW0wdMTKg8Ww/yx2C0phS87fHcmB/oou2DvFZuQ3ZufgDa0h9fJ/m/Q KMu5xen2ed/kXcivwq7jCxngGjgqrc4Scrsps22eUurjrxqRnEz5FupO1EP6vba0YRCv ZQ3N2o5QyBcdBcG4Hh16Wl8sA9YdvDW6/nApnH8ZqURTGFHAvrs3WnNiMRdPNoF/z5To tkeA== X-Gm-Message-State: AFqh2konqvGKkJPsHldO3254crd1JpjtWzM0b4/BOUBHPIft+SUHT//n I6os5aQ+y5OfgqfogfBLZHuygcgjHO9QuXJo/xW7EQdi4ItP1jJb X-Google-Smtp-Source: AMrXdXuNezomjN+A9N+Al7GlcSDUye1vTPCcqSeGlqyvl3Hc81bQK3Vz8U0t3OxzFMrlbpC0jyHfUbmXOrOgWQA5m1Y= X-Received: by 2002:a17:906:dfc1:b0:7bd:3a5c:4dea with SMTP id jt1-20020a170906dfc100b007bd3a5c4deamr2039312ejc.190.1674327146342; Sat, 21 Jan 2023 10:52:26 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Sat, 21 Jan 2023 10:52:14 -0800 Message-ID: Subject: Re: A way to untie -T vars? To: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 28697 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: On Sat, Jan 21, 2023 at 9:11 AM Bart Schaefer wrote: > > % typeset -a FOO=($FOO) foo=($foo) Speaking of unorthodoxy ... % typeset -T FOO foo % typeset foo=bar typeset: foo: inconsistent type for assignment % typeset -i foo=1 % typeset -p FOO foo typeset: no such variable: FOO typeset -i foo=1 % So ... with "typeset" I can forcibly convert a tied scalar to an array, or an array to an integer, but there's no way to convert an array to an ordinary scalar. Anyway ... 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 }