Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] type -w += suffix alias
- X-seq: zsh-workers 36403
 
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
 
- To: zsh-workers@xxxxxxx
 
- Subject: [PATCH] type -w += suffix alias
 
- Date: Wed, 2 Sep 2015 15:33:22 +0000
 
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	daniel.shahaf.name; h=content-type:date:from:message-id	:mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=WH6	lOEVK0TpkDWToKjfQEJ5/bes=; b=sJxCW60qLz3FfRui+3hz25+CGs4lmDmZc/5	L1YUXoiM3tAla+X3ICHCP9PdhtdDvcLpLbu6tNuIwq+B9kIJuVL2l+sfN5E2ZBw5	eajOz+jC5A7Uvnt+u4b0mVVQbucrUgjaFRaq8RlSEJ6qs+AaefL6xS3kdGenrRkY	M4mgvntU=
 
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	messagingengine.com; h=content-type:date:from:message-id	:mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=WH	6lOEVK0TpkDWToKjfQEJ5/bes=; b=hDPSVi/se97VIqGrSnipHZxajYPDkCu+OR	VHExGCmrDsaKtBu5AYbCH7zIf1XbS46MVOKdPymVf00Oscdrics+R+WA6aF1Dik7	Sj26hx0y4S1cci2Q8zUotY2Q2aXCMBe4uEXKA0pyZ62ya3Z+7k7O/R4rpYXmVxLQ	MgqD61/ic=
 
- List-help: <mailto:zsh-workers-help@zsh.org>
 
- List-id: Zsh Workers List <zsh-workers.zsh.org>
 
- List-post: <mailto:zsh-workers@zsh.org>
 
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
 
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