zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Amusing (?) behavior of zsh/parameter specials
Date: Mon, 25 Jan 2016 21:11:40 -0800	[thread overview]
Message-ID: <160125211140.ZM15762@torch.brasslantern.com> (raw)
In-Reply-To: <20160124182611.710b0fba@ntlworld.com>

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.


  reply	other threads:[~2016-01-26  5:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-23 17:07 Bart Schaefer
2016-01-24 18:26 ` Peter Stephenson
2016-01-26  5:11   ` Bart Schaefer [this message]
2016-01-26  9:58     ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160125211140.ZM15762@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).