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

[PATCH] type -w += suffix alias



This makes 'type -w' distinguish suffix aliases from regular aliases,
like bare 'type' already does.

Use-case: detecting programmatically whether the command word is indeed
a valid command word (see <https://github.com/zsh-users/zsh-syntax-highlighting/issues/126>)

diff --git a/Src/hashtable.c b/Src/hashtable.c
index 90739a8..2d1ff87 100644
--- a/Src/hashtable.c
+++ b/Src/hashtable.c
@@ -1234,7 +1234,10 @@ printaliasnode(HashNode hn, int printflags)
     }
 
     if (printflags & PRINT_WHENCE_WORD) {
-	printf("%s: alias\n", a->node.nam);
+	if (a->node.flags & ALIAS_SUFFIX)
+	    printf("%s: suffix alias\n", a->node.nam);
+	else
+	    printf("%s: alias\n", a->node.nam);
 	return;
     }
 
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index b294e65..3896178 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -91,5 +91,8 @@
 0:unalias -a
 
   alias -s foo=print
+  type bar.foo; type -w bar.foo
   unalias -as
 0:unalias -as
+>foo is a suffix alias for print
+>foo: suffix alias



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