Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion problem with '291' ok with '274'.
n Feb 11, 8:00pm, Bart Schaefer wrote:
}
} I'm not sure about the exec.c change that moved the "if (do_exec)" block,
} but I'm wondering whether it has to do with Ray's mysterious shell exits,
} because it makes an _exit() call.
And sure enough ...
On Feb 11, 9:06pm, Ray Andrews wrote:
} Subject: Re: completion problem with '291' ok with '274'.
}
} Breakpoint 2, _exit () at ../sysdeps/unix/sysv/linux/i386/_exit.S:24
} 24 ../sysdeps/unix/sysv/linux/i386/_exit.S: No such file or directory.
} (gdb) where
} #0 _exit () at ../sysdeps/unix/sysv/linux/i386/_exit.S:24
} #1 0xb7dda0e7 in __run_exit_handlers (status=status@entry=0,
} listp=0xb7f503c4 <__exit_funcs>,
} run_list_atexit=run_list_atexit@entry=true) at exit.c:97
} #2 0xb7dda17d in __GI_exit (status=0) at exit.c:104
} #3 0x080667a3 in execcmd (state=0xbfffa8a0, input=0, output=0, how=18,
} last1=1) at exec.c:3494
So basically we have to back out all of 34485 and start that over.
Here's the reverse diff for 34485:
diff --git a/Src/exec.c b/Src/exec.c
index 9bbcf49..3b0e936 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2427,7 +2427,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
wordcode code;
Wordcode beg = state->pc, varspc;
FILE *oxtrerr = xtrerr, *newxtrerr = NULL;
- LinkList restorelist = 0, removelist = 0;
doneps4 = 0;
redir = (wc_code(*state->pc) == WC_REDIR ? ecgetredirs(state) : NULL);
@@ -3360,9 +3359,9 @@ execcmd(Estate state, int input, int output, int how, int last1)
zcontext_restore();
} else
redir_prog = NULL;
-
+
lastval = execfuncdef(state, redir_prog);
- }
+ }
else if (type >= WC_CURSH) {
if (last1 == 1)
do_exec = 1;
@@ -3375,6 +3374,7 @@ execcmd(Estate state, int input, int output, int how, int last1)
} else
lastval = (execfuncs[type - WC_CURSH])(state, do_exec);
} else if (is_builtin || is_shfunc) {
+ LinkList restorelist = 0, removelist = 0;
/* builtin or shell function */
if (!forked && ((cflags & BINF_COMMAND) ||
@@ -3424,6 +3424,29 @@ execcmd(Estate state, int input, int output, int how, int last1)
} else
clearerr(stdout);
}
+ if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
+ lastval && !subsh) {
+#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
+ fprintf(stderr, "zsh: exit %lld\n", lastval);
+#else
+ fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
+#endif
+ fflush(stderr);
+ }
+
+ if (do_exec) {
+ if (subsh)
+ _exit(lastval);
+
+ /* If we are exec'ing a command, and we are not in a subshell, *
+ * then check if we should save the history file. */
+ if (isset(RCS) && interact && !nohistsave)
+ savehistfile(NULL, 1, HFILE_USE_OPTIONS);
+ exit(lastval);
+ }
+ if (restorelist)
+ restore_params(restorelist, removelist);
+
} else {
if (!forked)
setiparam("SHLVL", --shlvl);
@@ -3473,28 +3496,6 @@ execcmd(Estate state, int input, int output, int how, int last1)
execlist(state, 0, 1);
}
}
- if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
- lastval && !subsh) {
-#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD)
- fprintf(stderr, "zsh: exit %lld\n", lastval);
-#else
- fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
-#endif
- fflush(stderr);
- }
-
- if (do_exec) {
- if (subsh)
- _exit(lastval);
-
- /* If we are exec'ing a command, and we are not in a subshell, *
- * then check if we should save the history file. */
- if (isset(RCS) && interact && !nohistsave)
- savehistfile(NULL, 1, HFILE_USE_OPTIONS);
- exit(lastval);
- }
- if (restorelist)
- restore_params(restorelist, removelist);
}
err:
diff --git a/Src/parse.c b/Src/parse.c
index ffd25de..0b54a90 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1612,7 +1612,8 @@ par_funcdef(int *cmplx)
num++;
zshlex();
}
- *cmplx = 1;
+ if (num > 0)
+ *cmplx = 1;
ecbuf[parg] = ecused - parg; /*?*/
ecbuf[parg+1] = num;
}
@@ -1896,7 +1897,8 @@ par_simple(int *cmplx, int nr)
argc++;
zshlex();
}
- *cmplx = 1;
+ if (argc > 0)
+ *cmplx = 1;
ecbuf[parg] = ecused - parg; /*?*/
ecbuf[parg+1] = argc;
}
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 3213534..46b1837 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -783,24 +783,14 @@
>print is a shell builtin
?(eval):8: command not found: print
-# PRINTEXITVALUE only works if shell input is coming from standard input.
-# Goodness only knows why.
- $ZTST_testdir/../Src/zsh -f <<<'
- setopt printexitvalue
- func() {
- false
- }
- func
- '
-1:PRINT_EXIT_VALUE option
-?zsh: exit 1
-
- $ZTST_testdir/../Src/zsh -f <<<'
- setopt printexitvalue
- () { false; }
- '
-1:PRINT_EXIT_VALUE option for anonymous function
-?zsh: exit 1
+# This option seems to be problematic. I don't quite know how it works.
+## func() {
+## setopt localoptions printexitvalue
+## false
+## }
+## func
+## 1:PRINT_EXIT_VALUE option
+## ?(eval):2: exit 1
setopt promptbang
print -P !
Messages sorted by:
Reverse Date,
Date,
Thread,
Author