zsh-workers
 help / color / mirror / code / Atom feed
From: Joey Pabalinas <joeypabalinas@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Joey Pabalinas <joeypabalinas@gmail.com>,
	"zsh-workers@zsh.org" <zsh-workers@zsh.org>
Subject: Re: [PATCH] Allow '=' aliases to be used with -L
Date: Wed, 21 Mar 2018 16:58:07 -1000	[thread overview]
Message-ID: <20180322025807.u3y7dph2vi6ls2ll@gmail.com> (raw)
In-Reply-To: <CAH+w=7aC9qsUaqz6arQitzoZsCXjeedSX5zUYE_Qwd-CLNQX6Q@mail.gmail.com>

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

On Wed, Mar 21, 2018 at 06:37:37PM -0700, Bart Schaefer wrote:
> Unfortunately you can't put this in the base shell, because assignment
> to the aliases array is only supported by a module.

Ah you are right, I didn't realize that. How about if we check if the
module is loaded first? If it happens to not be we can just use the
old failure path.

Revised patch below:

 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/Src/hashtable.c b/Src/hashtable.c
index b7baa314220509240d..53e7e99e1a9f1505b6 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -1303,11 +1303,23 @@ printaliasnode(HashNode hn, int printflags)
     }
 
     if (printflags & PRINT_LIST) {
-	/* Fast fail on unrepresentable values. */
+	/*
+	 * '=' aliases need to be special cased with direct alias
+	 * table assignment (`aliases[=]=...`). If the zsh/parameter
+	 * module isn't loaded just print a warning and fail.
+	 */
 	if (strchr(a->node.nam, '=')) {
-	    zwarn("invalid alias '%s' encountered while printing aliases", 
-		  a->node.nam);
-	    /* ### TODO: Return an error status to the C caller */
+	    /* Fast fail on unrepresentable values. */
+	    if (!module_loaded("zsh/parameter")) {
+		zwarn("invalid alias '%s' encountered while printing aliases",
+		 a->node.nam);
+		/* ### TODO: Return an error status to the C caller */
+		return;
+	    }
+
+	    printf("aliases[=]=");
+	    quotedzputs(a->text, stdout);
+	    putchar('\n');
 	    return;
 	}
 
-- 
2.16.2

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-03-22  2:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22  1:19 Joey Pabalinas
2018-03-22  1:37 ` Bart Schaefer
2018-03-22  2:58   ` Joey Pabalinas [this message]
2018-03-22  3:08     ` Bart Schaefer
2018-03-22  3:12       ` Joey Pabalinas
2018-03-23  6:32     ` Daniel Shahaf
2018-03-23  7:39       ` Joey Pabalinas
2018-03-23 10:09 ` Nikolay Aleksandrovich Pavlov (ZyX)
2018-03-23 10:36   ` Joey Pabalinas
2018-03-23 17:29 ` Stephane Chazelas
2018-03-24  0:02   ` Bart Schaefer

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=20180322025807.u3y7dph2vi6ls2ll@gmail.com \
    --to=joeypabalinas@gmail.com \
    --cc=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).