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

[PATCH 1/2] alias -L: Emit aliases that begin with a plus sign correctly.



---
Without this series:

% alias -- +foo=42
% alias -L
alias +foo=42
alias run-help=man
alias which-command=whence
% eval $(alias -L)
zsh: bad option: -f

Reported as z-sy-h issue #392.

Sideline: how to make the workflow 
    x=`alias -L`
    unalias -m \*
    ...
    eval $x
work under released versions, that have this bug?

This is for z-sy-h, so the ellipsis is sourced with user settings in effect,
and needs to change global state.  Ideas so far are to define an 'alias'
function [but that would overwrite a user-defined function by that name]; to
use 'zcompile -U' or 'autoload -U' with a second file; or to somehow arrange
for aliases that begin with a '+' to be exempted from being undefined and from
being redefined.

Cheers,

Daniel

 Src/hashtable.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Src/hashtable.c b/Src/hashtable.c
index 2d5af5b..7c33675 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -1291,9 +1291,9 @@ printaliasnode(HashNode hn, int printflags)
 	else if (a->node.flags & ALIAS_GLOBAL)
 	    printf("-g ");
 
-	/* If an alias begins with `-', then we must output `-- ' *
+	/* If an alias begins with `-' or `+', then we must output `-- '
 	 * first, so that it is not interpreted as an option.     */
-	if(a->node.nam[0] == '-')
+	if(a->node.nam[0] == '-' || a->node.nam[0] == '+')
 	    printf("-- ");
     }
 



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