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

Re: something strange with compset and/or _normal



Andrej Borsenkow wrote:

> I try to complete after sudo; the relevant part (albeit clumsy) is
> 
> if [[ $cmd -gt 0 ]] && compset -n $cmd
> then
>     _normal
> 
> where ``cmd'' is position of command to execute and is computed somewhere
> else.
> 
> Unfortunately, that is what I get in log:
> + [[ -z _umount ]]
> + _sudo

A bug with the execution-optimisation patch that showed up when
shell functions called themselves recursively.

Bye
 Sven

diff -u os/exec.c Src/exec.c
--- os/exec.c	Tue Jun  8 15:23:06 1999
+++ Src/exec.c	Thu Jun 10 17:15:35 1999
@@ -1955,7 +1954,6 @@
 
 	    if (is_shfunc) {
 		/* It's a shell function */
-		LinkList tmpa = cmd->args;
 		int ofl = cmd->flags;
 
 #ifdef PATH_DEV_FD
@@ -1968,10 +1966,8 @@
 		if (subsh_close >= 0)
 		    zclose(subsh_close);
 		subsh_close = -1;
-		cmd->args = args;
 		cmd->flags = flags;
-		execshfunc(cmd, (Shfunc) hn);
-		cmd->args = tmpa;
+		execshfunc(cmd, (Shfunc) hn, args);
 		cmd->flags = ofl;
 #ifdef PATH_DEV_FD
 		for (i = 10; i <= max_zsh_fd; i++)
@@ -2775,7 +2771,7 @@
 
 /**/
 static void
-execshfunc(Cmd cmd, Shfunc shf)
+execshfunc(Cmd cmd, Shfunc shf, LinkList args)
 {
     LinkList last_file_list = NULL;
 
@@ -2793,9 +2789,9 @@
     if (isset(XTRACE)) {
 	LinkNode lptr;
 	fprintf(stderr, "%s", prompt4 ? prompt4 : prompt4);
-	if (cmd->args)
-	    for (lptr = firstnode(cmd->args); lptr; incnode(lptr)) {
-		if (lptr != firstnode(cmd->args))
+	if (args)
+	    for (lptr = firstnode(args); lptr; incnode(lptr)) {
+		if (lptr != firstnode(args))
 		    fputc(' ', stderr);
 		fprintf(stderr, "%s", (char *)getdata(lptr));
 	    }
@@ -2803,7 +2799,7 @@
 	fflush(stderr);
     }
 
-    doshfunc(shf->nam, shf->funcdef, cmd->args, shf->flags, 0);
+    doshfunc(shf->nam, shf->funcdef, args, shf->flags, 0);
 
     if (!list_pipe)
 	deletefilelist(last_file_list);

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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