We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This looks like a bug to me. This is using tcsh 6.20.00:
bash-4.4$ csh -c 'false || exit; echo hello' hello bash-4.4$
Why didn't the shell exit prior to executing the 'echo hello' command?
It seems as if the exit has a delayed effect and happens only after the entire list has been executed.
In an interactive shell, one sees:
bash-4.4$ csh schorr@ti129: false || exit; echo hello hello exit bash-4.4$
The text was updated successfully, but these errors were encountered:
I got used to this behavior, thus no longer saw it as a bug. I found it useful for one-line procedures.
( exit ( -e myfile ) && ( ( echo mytext > myfile ) >& /dev/null || echo Cannot create file. ) || echo File exists.
Anyhow, this behavior can be avoided with the following patch.
--- a/sh.sem.c +++ b/sh.sem.c @@ -658,13 +658,15 @@ execute(struct command *t, volatile int wanttty, int *pipein, int *pipeout, if (setexit() == 0) func(t, bifunc); resexit(oldexit); - haderr = ohaderr; if (adrof(STRprintexitvalue)) { int rv = getstatus(); if (rv != 0) xprintf(CGETS(17, 2, "Exit %d\n"), rv); } + if (bifunc->bfunct == doexit && !haderr) + reset(); + haderr = ohaderr; } break; }
Should be noted this doesn't work for one-line ifs, and I don't think would make a problem, since exit inherits the same expressiveness of if.
if
exit
Sorry, something went wrong.
No branches or pull requests
This looks like a bug to me. This is using tcsh 6.20.00:
bash-4.4$ csh -c 'false || exit; echo hello'
hello
bash-4.4$
Why didn't the shell exit prior to executing the 'echo hello' command?
It seems as if the exit has a delayed effect and happens only after the entire list has been executed.
In an interactive shell, one sees:
bash-4.4$ csh
schorr@ti129: false || exit; echo hello
hello
exit
bash-4.4$
The text was updated successfully, but these errors were encountered: