Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Allow '=' aliases to be used with -L



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: signature.asc
Description: PGP signature



Messages sorted by: Reverse Date, Date, Thread, Author