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.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,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 29E192C8E6 for ; Tue, 5 Mar 2024 02:05:45 +0100 (CET) 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:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=HQu+0DzfXE6mer+X7eIa1cMfvhOrph2apVVPNv00HyA=; b=SwRt/8z5jSV2zK8KRizkjrKF5b asPmTx5CDfuNtkN4PrK7KpxaxpYGY3k0hCNNY2g17nS/LBjLvlYDaHMoOBTZOKyU9bqsEoQSkqcXJ DL2bsNvArQz08kDtFFxtM4RNnhHn34ew+aDFumU9EHN9sS/vMjMIkVC8ncx+53wQl/o8ZdEg1ZYW6 W6fw9+oASSCarx59HnDTAM/f5RQ0mRN5LyaLfGmZojOdQa5HbN26RokICEsGPHdchVeVZqFTl3tfZ ahfx8qL4V6vhuSuVZiTEooSkLg1R5wgAHfaPBgOopezkMB1p3YbvcPE+j0OEDu5+gBBmRSVX+qT6l YLK77sGw==; Received: by zero.zsh.org with local id 1rhJFZ-0004NP-BH; Tue, 05 Mar 2024 01:05:45 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rhJEy-00043S-Tx; Tue, 05 Mar 2024 01:05:09 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.97.1) (envelope-from ) id 1rhJEt-00000000NeT-1CCv; Tue, 05 Mar 2024 02:05:08 +0100 cc: Zsh hackers list In-reply-to: From: Oliver Kiddle References: <20240220210553.g6imt3op6zahz4pa@chazelas.org> <20240221201215.anpjcfav6na55gg6@chazelas.org> <20240301182238.tpyajwblbam5bxw7@chazelas.org> <20240303134413.74c7trikf73g5kjy@chazelas.org> <20240303202756.7axmzy6gkohza2ra@chazelas.org> To: Bart Schaefer Subject: Re: Up-scope named references, vs. ksh MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <90919.1709600703.1@hydra> Date: Tue, 05 Mar 2024 02:05:03 +0100 Message-ID: <90920-1709600703.280388@Hl_Q.k_r5.OUBX> X-Seq: 52676 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: Bart Schaefer wrote: > The word "scalar" is just as important in that sentence as the word > "global" -- "read" and "zstat" can specify whether the variable is > scalar or array, you can't do that with a nameref. Furthermore, if Isn't defaulting to a scalar type fairly normal. For the read use case, it works for some basic tests when you start the function with: [[ -v $1 ]] || typeset -g $1 typeset -un ref=$1 A different problem I'm finding is with not being able to hide the reference type of a variable in a called function: inner() { local var=hello typeset -p var } outer() { typeset -n var=value inner } outer This outputs typeset -g -n var=value The value "hello" is lost but a subsequent assignment within inner() applies to the reference. I would expect the `local var` in inner to hide any variable including references with the same name from an outer scope. (I'm currently testing with the typeset -nu and Fix crash on unset-through-nameref patches applied). Oliver