diff options
| author | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-15 15:20:17 +0000 |
|---|---|---|
| committer | Sean Kurtz <seankurtz75@gmail.com> | 2026-11-15 15:20:17 +0000 |
| commit | 426042660d937ada13bfa53881f6a3217d64a13b (patch) | |
| tree | d1fb867a8851f28074bbd121ee68852f77055219 /src/exec.c | |
| parent | cb18afdf0a45bcee8b382d9f9a1249b1c4db2a20 (diff) | |
| download | zash-426042660d937ada13bfa53881f6a3217d64a13b.tar.gz | |
Add [[ ]], make coverage, and fixes found by edge-case tests
[[ ]] is parsed into a tree and evaluated without argv or lookup.
Fixes: errexit inside a tested subshell, the ${x:?} message, arithmetic
on variables holding expressions, printf %c of an empty argument,
job text for arithmetic, and \n and \e prompt escapes.
Diffstat (limited to 'src/exec.c')
| -rw-r--r-- | src/exec.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -446,6 +446,7 @@ static int exec_error(const char *name, int err) { static _Noreturn void exec_path(const char *path, char **argv, char **envp) { flush_all(); trap_reset_child(); + COVERAGE_FLUSH(); execve(path, argv, envp); if (errno == ENOEXEC) { char **nv = script_argv(path, argv); @@ -1544,6 +1545,9 @@ static int eval_subshell(node *n, unsigned flags) { trap_reset_child(); /* already the last thing this shell does */ in_subshell = true; } + /* `( false; echo x ) || y`: errexit is ignored inside, too. */ + if (flags & EV_TESTED) + opt.errexit = false; redirsave rs; if (n->redirs && !redir_push(n->redirs, &rs)) exit_shell(1); @@ -1647,6 +1651,18 @@ int eval_node(node *n, unsigned flags) { case N_FUNC: func_define(n->u.func.name, n->u.func.body, n->u.func.arena); break; + case N_COND: + cur_lineno = n->lineno; + if (opt.xtrace) { + char *text = node_text(n); + out_printf(&out2, "%s%s\n", var_get("PS4") ? var_get("PS4") : "+ ", + text); + out_flush(&out2); + free(text); + } + status = eval_cond(n->u.cond); + leaf = true; + break; case N_ARITH: /* (( expr )): true when the value is not zero. */ cur_lineno = n->lineno; |
