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

PATCH: shell function context for substitution



Minor fix for ~[...]: it doesn't set a shell function context.  The only
consequence I'm aware of that would be visible is an error message when
debugging is turned on when it autoloads zsh_directory_name because it
tries to turn the code into text and can't because it hasn't yet been
loaded.

The cleanest fix is to make this a new context.  I don't think the
specific contexts are used anywhere, just the fact that there is on.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.202
diff -u -r1.202 utils.c
--- Src/utils.c	27 Sep 2008 23:15:10 -0000	1.202
+++ Src/utils.c	29 Sep 2008 15:08:51 -0000
@@ -2935,14 +2935,23 @@
 char **
 subst_string_by_func(Shfunc func, char *arg1, char *orig)
 {
+    int osc = sfcontext;
     LinkList l = newlinklist();
+    char **ret;
+
     addlinknode(l, func->node.nam);
     if (arg1)
 	addlinknode(l, arg1);
     addlinknode(l, orig);
+    sfcontext = SFC_SUBST;
+
     if (doshfunc(func, l, 1))
-	return NULL;
-    return getaparam("reply");
+	ret = NULL;
+    else
+	ret = getaparam("reply");
+
+    sfcontext = osc;
+    return ret;
 }
 
 /**/
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.146
diff -u -r1.146 zsh.h
--- Src/zsh.h	11 Sep 2008 12:49:20 -0000	1.146
+++ Src/zsh.h	29 Sep 2008 15:08:52 -0000
@@ -1076,6 +1076,7 @@
 #define SFC_WIDGET   4		/* user defined widget */
 #define SFC_COMPLETE 5		/* called from completion code */
 #define SFC_CWIDGET  6		/* new style completion widget */
+#define SFC_SUBST    7          /* used to perform substitution task */
 
 /* tp in funcstack */
 

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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