Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID
	autolearn=ham autolearn_force=no version=3.4.0
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=brasslantern-com.20150623.gappssmtp.com; s=20150623;
        h=from:message-id:date:in-reply-to:comments:references:to:subject
         :mime-version:content-type;
        bh=6NtiP29wKsMZENy5ZsG3bwevRdXRyQdwk+UrWd5iO2Y=;
        b=1Y6dL/EtNE6kdw0x0+QvgvLILDxekVwm2XvDJggS6kxcVtip55z+blVLGrJQzXbTRW
         24x8esNNTC2Gju0hICYjN7ZJsGQy5oN3ToYTMK+1GgME6opyUWFV+C6+elMswJsV/vJt
         FYSn2OfvmCwgPT/p7G4lw+eRgTKInmjsC0iEW2wSNuQctRVW/dECL0HsPz3ElrP1AV/l
         85R6mBg+HXh8RBqY4koUSAtYGgGOdGCv8oMz3IeCzQKTqJGX/XWDmLnTbsKl4PLSff4s
         w+mOjWT+uuVcRa90Y5B7qw1H6c0WZi3r2KsnaU84lvSwSSENluk5uonKcTK3Oyx1D5ik
         m4cA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:date:in-reply-to:comments
         :references:to:subject:mime-version:content-type;
        bh=6NtiP29wKsMZENy5ZsG3bwevRdXRyQdwk+UrWd5iO2Y=;
        b=Q3emr+eg69t8TD95DG3+SL72nkmRoaeWZ+eIXJ5TrbBiahY55AGfLWZ8FwmthPFZSd
         zQ1YPFC5nGQLkfhO93Pb3dJmcRGW9v5FQkPn2+uLMSKc/7EyYCppTXPNgn2FNcT+DbDZ
         sUcxXhWQd+hrvITKMob98+e6oXPCwjYcVHnjkbMgp1vbgbizsx8IecDvGaiWpfrGPHWw
         KzP/rSfyoRWE27D/lRrA9+jFIAseZFzxhfXEYlcf6jdtUSdpM8C5KbDs1N50o1Z9kJtN
         YT/aeJlaIOWWQPgTjb5xBMZ5N5OnVAOSu2eUFK8ffi78rjrgaeuI9R8S6TppSy6ONAyR
         O9uw==
X-Gm-Message-State: AG10YOSg4yEnBwq/66lw1Cszwpm0IOC+5MXFTBxIrSy9j6UYa4pMnz7U/xTszumY89puMA==
X-Received: by 10.66.194.230 with SMTP id hz6mr20742703pac.70.1453785059248;
        Mon, 25 Jan 2016 21:10:59 -0800 (PST)
From: Bart Schaefer <schaefer@brasslantern.com>
Message-Id: <160125211140.ZM15762@torch.brasslantern.com>
Date: Mon, 25 Jan 2016 21:11:40 -0800
In-Reply-To: <20160124182611.710b0fba@ntlworld.com>
Comments: In reply to Peter Stephenson <p.w.stephenson@ntlworld.com>
        "Re: Amusing (?) behavior of zsh/parameter specials" (Jan 24,  6:26pm)
References: <160123090736.ZM14384@torch.brasslantern.com> 
	<20160124182611.710b0fba@ntlworld.com>
X-Mailer: OpenZMail Classic (0.9.2 24April2005)
To: zsh-workers@zsh.org
Subject: Re: Amusing (?) behavior of zsh/parameter specials
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Seq: zsh-workers 37785

On Jan 24,  6:26pm, Peter Stephenson wrote:
} Subject: Re: Amusing (?) behavior of zsh/parameter specials
}
} On Sat, 23 Jan 2016 09:07:36 -0800
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > Maybe autoloaded parameters should always be hidden until they load?
} 
} That's definitely arguable, yes.  -p and its features are there as a
} concession to POSIX-style order, in order to make it easy to restore
} parameters the user has defined, and autoloaded parameters, whether
} disappearing or not, don't fit that picture.

Two competing potential patches for this.


I lean a little bit toward this one:

diff --git a/Src/params.c b/Src/params.c
index b2e8897..a1f0292 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5258,7 +5258,8 @@ printparamnode(HashNode hn, int printflags)
 
     if (printflags & PRINT_TYPESET) {
 	if ((p->node.flags & (PM_READONLY|PM_SPECIAL)) ==
-	    (PM_READONLY|PM_SPECIAL)) {
+	    (PM_READONLY|PM_SPECIAL) ||
+	    (p->node.flags & PM_AUTOLOAD)) {
 	    /*
 	     * It's not possible to restore the state of
 	     * these, so don't output.


But this one has its attractions as well:

diff --git a/Src/params.c b/Src/params.c
index b2e8897..0ec0042 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5265,7 +5265,10 @@ printparamnode(HashNode hn, int printflags)
 	     */
 	    return;
 	}
-	printf("typeset ");
+	if (p->node.flags & PM_AUTOLOAD)
+	    printf("unset ");
+	else
+	    printf("typeset ");
     }
 
     /* Print the attributes of the parameter */


The main problem with the latter one is that, if the parameter really
is read-only after autoloading, "restoring" the unset will fail.  I
guess the point is to restore the parameters that ARE set, so now that
I've written this all down I lean even more to the first variant.

