help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: [PATCH] More typeset -p troubles
Date: Mon, 13 Mar 2023 19:58:33 -0700	[thread overview]
Message-ID: <CAH+w=7bAy-Xsy1Ei6d_MEg20HUwBQayFFt2AETZXS0hqs8oZZA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

The "-m pattern" option is supposed to enable printing namespaces, but
that didn't work when combined with -p.

The -p option could also cause an unset parameter to become set if a
named reference pointed at it.

Noticed but NOT fixed here:  The "-p 1" option (add newlines within
array assignment output) does not work when combined with "-m".

[-- Attachment #2: more-typeset-p.txt --]
[-- Type: text/plain, Size: 1109 bytes --]

diff --git a/Src/builtin.c b/Src/builtin.c
index d99802f5f..f38a54936 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2236,12 +2236,12 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 	on &= ~PM_LOCAL;
 	if (!on && !roff && !ASG_VALUEP(asg)) {
+	    int with_ns = OPT_ISSET(ops,'m') ? PRINT_WITH_NAMESPACE : 0;
 	    if (OPT_ISSET(ops,'p'))
-		paramtab->printnode(&pm->node, PRINT_TYPESET);
+		paramtab->printnode(&pm->node, PRINT_TYPESET|with_ns);
 	    else if (!OPT_ISSET(ops,'g') &&
 		     (unset(TYPESETSILENT) || OPT_ISSET(ops,'m')))
-		paramtab->printnode(&pm->node,
+		paramtab->printnode(&pm->node, PRINT_INCLUDEVALUE|with_ns);
 	    return pm;
 	if ((pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
@@ -2502,6 +2502,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 		    "%s: inconsistent array element or slice assignment", pname);
 	    return NULL;
+    } else if (!pm && OPT_ISSET(ops,'p')) {
+	return NULL;
      * As we can hide existing parameters, we allow a name if

                 reply	other threads:[~2023-03-14  2:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

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

  git send-email \
    --in-reply-to='CAH+w=7bAy-Xsy1Ei6d_MEg20HUwBQayFFt2AETZXS0hqs8oZZA@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \


* 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


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).