summaryrefslogtreecommitdiff
path: root/Src/exec.c
AgeCommit message (Collapse)AuthorFilesLines
2025-01-27github #126: Fix some typosWu, Zhenyu1-2/+2
2024-12-2653257: use monotonic clock where appropriatedana1-11/+10
update the following features to use the monotonic clock for calculating time deltas and intervals: * MAILCHECK parameter * PERIOD parameter * SECONDS parameter * %(nS.t.f) prompt-expansion sequence * time built-in's elapsed time and cpu % values * zsh/zftp ZFTP_TMOUT parameter * zsh/zprof timings also use CLOCK_MONOTONIC_RAW instead of CLOCK_MONOTONIC on macOS
2024-10-1653146: flags cannot be copied from an undefined function (cf. ca6f4466)Bart Schaefer1-1/+2
2024-09-1453088: enable `time' on builtins, assignments, and current-shell actionsBart Schaefer1-2/+40
2024-08-0453005: off-by-one error when resetting signals on subshell entrancePhilippe Altherr1-2/+2
2024-07-0452985: avoid adding original param to restorelistJun-ichi Takimoto1-4/+3
2024-06-2852977: ERR_EXIT/ERR_RETURN are respected by the final command in && / || listsPhilippe Altherr1-0/+1
2024-03-1852750: remove ansi2knr support for old pre-ansi K&R compilersOliver Kiddle1-1/+1
2024-03-0452650 plus minor fixes: add -u for named references pointing to "upper" scopeBart Schaefer1-1/+21
2024-02-2852594: support for POSIX real-time signals with kill and trapOliver Kiddle1-1/+1
Also add new -L option to kill for a more verbose listing of signals
2024-02-24Fix META_NOALLOC to META_STATIC in 'bad interpreter' metafyBart Schaefer1-2/+2
2024-02-2452596: metafy interpreter name for error messageBart Schaefer1-3/+3
2024-02-1845837: fix process group restoration upon exitStephane Chazelas1-1/+1
2024-02-1852515: (+ tests in 52527) avoid sh errors when running shebang-less scripts ↵Stephane Chazelas1-2/+15
with paths starting with - or +
2023-11-1852313: Src/exec.c: multios are not interactive and check for write errors.Bart Schaefer1-2/+6
2023-11-1552309: fix cases that hang with all signals blocked.Bart Schaefer1-2/+2
* no job control inside <<(substition) * allow interrupt of multios reading from a terminal
2023-10-24github #104: fix small typoErrrorMaxx1-1/+1
2023-09-1052125: getoutput() must not free() after gettempname(..., 1) for heapBart Schaefer1-1/+0
2023-04-1751652: fix running of TRAPEXIT explicitly.Peter Stephenson1-1/+33
This is a special case where TRAPEXIT is unset within a TRAPEXIT as it should never run in a nested context, so just save the function structure temporarily on the heap.
2023-04-0951632: nmetafy $_ when exporting it to childJun-ichi Takimoto1-1/+1
2023-03-2951608: Don't execute commands after "continue &&"Peter Stephenson1-2/+2
Also ! continue ||
2023-02-1451424: $(<...) shouldn't try to open a file with NO_EXECPeter Stephenson1-0/+3
2022-12-1651212: remove STOUC() macroOliver Kiddle1-1/+1
This served as a workaround for ancient compilers where casts to unsigned char were broken.
2022-12-1351210: Clear errflag before calling EXIT trapBart Schaefer1-0/+4
If this is not done, special cases such as failures in special builtins or errors in math expressions skip the trap execution.
2022-12-1251134: ! return doesn't change the return statusPeter Stephenson1-1/+1
2022-12-0951161: correct errno after closing xtrace FDBart Schaefer1-0/+3
2022-12-0351094: consistent use of bit-manipulation for noerrexit value changesPhilippe Altherr1-3/+3
2022-12-0351098: remove unreachable NOERREXIT_UNTIL_EXEC code and effectsPhilippe Altherr1-12/+1
2022-12-0351076: fix ERR_EXIT when used with "eval" or "source"; documentary commentsPhilippe Altherr1-3/+43
2022-12-0351071: fix ERR_RETURN for functions in conditional statementsPhilippe Altherr1-7/+5
2022-12-0351001: fix for ERR_EXIT following shell function; update testsPhilippe Altherr1-9/+1
2022-12-0351001: fix for ERR_EXIT with pipeline negation ("!"); update testsPhilippe Altherr1-5/+8
2022-12-0351001: Reverts 8839e969b, most of 1ba8714a, and d873ed60.Philippe Altherr1-3/+1
Also correct ChangeLog
2022-11-0950929: fix handling of ERR_RETURN bent by 50928.Bart Schaefer1-1/+1
2022-11-0950928: fix tests for 50897, mention behavior change in NEWSBart Schaefer1-0/+2
2022-11-0950922: fix additional cases of signals for current shell jobs on the right ↵Bart Schaefer1-2/+6
of a pipeline. Backs out part of 188c5cd5 (workers/50874). With this change, after a new subshell is forked upon suspend of the right side of a pipeline, the previous foreground subjob is resumed first and the new subshell remains stopped until that job finishes.
2022-11-0850897: nonzero status of complex commands should trigger ERR_EXITBart Schaefer1-1/+1
2022-11-0250851: restore typtab when necessaryJun-ichi Takimoto1-0/+12
inittyptab() must be called when returning from a function with "setopt localoptions MULTIBYTE|BANGHIST|SHSTDIN", and also in function dosetopt() when setting these options (via $options, for example). We intentionally did not take account of the options EMACS/VI because these options are obsolete and their use is not recommended.
2022-04-2950136: Fix =(nosuchcommand) race/deadlock first reported in workers/42609Bart Schaefer1-4/+0
2022-04-2850162: Fix multios with current-shell "exec" (aka nullexec).Bart Schaefer1-0/+4
2022-04-2550049: care with signed charactersPeter Stephenson1-1/+1
Some signed-to-unsigned casts needed for a couple of cases of pointers used as indices.
2022-03-3049906 (Bart), 49911: Fixes to querying jobs in subshell.Peter Stephenson1-0/+1
Don't attempt to query invalid job off end of table, resulting in crashes from $jobtstates. If background task started in subshell, look at tatsks within subshell instead of main shell. Document and add test.
2022-03-3049813: <<<: Document newline behavior and fix optimizationMikael Magnusson1-1/+3
The =(<<<foo) optimization forgot to add a newline, but =(cat<<<foo) always did, make the behavior consistent, and document it.
2022-01-3049694 + doc: Allow using empty STTY= to freeze tty for a single commandMikael Magnusson1-2/+4
Previously, doing this would just run stty with no arguments, which normally causes it to print some terminal settings to stdout.
2021-11-12github #82: Fix typosDimitris Apostolou1-1/+1
2021-09-0949353: Fix comments in sourced file.Peter Stephenson1-1/+1
If the file was sourced from an interactive shell with INTERACTIVE_COMMENTS not set, comments were not parsed. Note there is a remaining edge case where the sourced file is in fact entered at the comment line.
2021-08-2649307 with doc update: POSIX_TRAPS fix.Peter Stephenson1-1/+2
With POSIX_TRAPS set, an ignored signal stays ignored when entering a subshell.
2021-05-1648857: declare "volatile" all globals that may be modified by signal handlersBart Schaefer1-3/+5
2021-04-1047794: exec: run final pipeline command in a subshell in sh modebrian m. carlson1-4/+6
zsh typically runs the final command in a pipeline in the main shell instead of a subshell. However, POSIX specifies that all commands in a pipeline run in a subshell, but permits zsh's behavior as an extension. The default /bin/sh implementations on various Linux distros and the BSDs always use a subshell for all components of a pipeline. Since zsh may be used as /bin/sh in some cases (such as macOS Catalina), it makes sense to have the common sh behavior when emulating sh, so do that by checking for being the final item of a multi-item pipeline and creating a subshell in that case. From the comment above execpline(), we know the following: last1 is a flag that this command is the last command in a shell that is about to exit, so we can exec instead of forking. It gets passed all the way down to execcmd() which actually makes the decision. A 0 is always passed if the command is not the last in the pipeline. […] If last1 is zero but the command is at the end of a pipeline, we pass 2 down to execcmd(). So there are three cases to consider in this code: • last1 is 0, which means we are not at the end of a pipeline, in which case we should not change behavior. • last1 is 1, which means we are effectively running in a subshell, because nothing that happens due to the exec is going to affect the actual shell, since it will have been replaced. So there is nothing to do here. • last1 is 2, which means our command is at the end of the pipeline, so in sh mode we should create a subshell by forking. input is nonzero if the input to this process is a pipe that we've opened. At the end of a multi-stage pipeline, it will necessarily be nonzero. Note that several of the tests may appear bizarre, since most developers do not place useless variable assignments directly at the end of a pipeline. However, as the function tests demonstrate, there are cases where assignments may occur when a shell function is used at the end of a command. The remaining assignment tests simply test additional cases, such as the use of local, that would otherwise be untested.
2021-02-16Allow more scripts without #!Justine Tunney1-4/+23
This change modifies the zsh binary safety check surrounding execve() so it can run shell scripts having concatenated binary content. We're using the same safety check as FreeBSD /bin/sh [1]. POSIX was recently revised to require this behavior: "The input file may be of any type, but the initial portion of the file intended to be parsed according to the shell grammar (XREF to XSH 2.10.2 Shell Grammar Rules) shall consist of characters and shall not contain the NUL character. The shell shall not enforce any line length limits." "Earlier versions of this standard required that input files to the shell be text files except that line lengths were unlimited. However, that was overly restrictive in relation to the fact that shells can parse a script without a trailing newline, and in relation to a common practice of concatenating a shell script ending with an 'exit' or 'exec $command' with a binary data payload to form a single-file self-extracting archive." [2] [3] One example use case of such scripts, is the Cosmopolitan C Library [4] which configuse the GNU Linker to output a polyglot shell+binary format that runs on Linux / Mac / Windows / FreeBSD / OpenBSD. [1] https://github.com/freebsd/freebsd-src/commit/9a1cd363318b7e9e70ef6af27d1675b371c16b1a [2] http://austingroupbugs.net/view.php?id=1250 [3] http://austingroupbugs.net/view.php?id=1226#c4394 [4] https://justine.lol/cosmopolitan/index.html