about summary refs log tree commit diff
path: root/Src/exec.c
Commit message (Collapse)AuthorAgeFilesLines
* 52313: Src/exec.c: multios are not interactive and check for write errors.Bart Schaefer2023-11-181-2/+6
|
* 52309: fix cases that hang with all signals blocked.Bart Schaefer2023-11-151-2/+2
| | | | | * no job control inside <<(substition) * allow interrupt of multios reading from a terminal
* github #104: fix small typoErrrorMaxx2023-10-241-1/+1
|
* 52125: getoutput() must not free() after gettempname(..., 1) for heapBart Schaefer2023-09-101-1/+0
|
* 51652: fix running of TRAPEXIT explicitly.Peter Stephenson2023-04-171-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.
* 51632: nmetafy $_ when exporting it to childJun-ichi Takimoto2023-04-091-1/+1
|
* 51608: Don't execute commands after "continue &&"Peter Stephenson2023-03-291-2/+2
| | | | Also ! continue ||
* 51424: $(<...) shouldn't try to open a file with NO_EXECPeter Stephenson2023-02-141-0/+3
|
* 51212: remove STOUC() macroOliver Kiddle2022-12-161-1/+1
| | | | | This served as a workaround for ancient compilers where casts to unsigned char were broken.
* 51210: Clear errflag before calling EXIT trapBart Schaefer2022-12-131-0/+4
| | | | | If this is not done, special cases such as failures in special builtins or errors in math expressions skip the trap execution.
* 51134: ! return doesn't change the return statusPeter Stephenson2022-12-121-1/+1
|
* 51161: correct errno after closing xtrace FDBart Schaefer2022-12-091-0/+3
|
* 51094: consistent use of bit-manipulation for noerrexit value changesPhilippe Altherr2022-12-031-3/+3
|
* 51098: remove unreachable NOERREXIT_UNTIL_EXEC code and effectsPhilippe Altherr2022-12-031-12/+1
|
* 51076: fix ERR_EXIT when used with "eval" or "source"; documentary commentsPhilippe Altherr2022-12-031-3/+43
|
* 51071: fix ERR_RETURN for functions in conditional statementsPhilippe Altherr2022-12-031-7/+5
|
* 51001: fix for ERR_EXIT following shell function; update testsPhilippe Altherr2022-12-031-9/+1
|
* 51001: fix for ERR_EXIT with pipeline negation ("!"); update testsPhilippe Altherr2022-12-031-5/+8
|
* 51001: Reverts 8839e969b, most of 1ba8714a, and d873ed60.Philippe Altherr2022-12-031-3/+1
| | | | Also correct ChangeLog
* 50929: fix handling of ERR_RETURN bent by 50928.Bart Schaefer2022-11-091-1/+1
|
* 50928: fix tests for 50897, mention behavior change in NEWSBart Schaefer2022-11-091-0/+2
|
* 50922: fix additional cases of signals for current shell jobs on the right ↵Bart Schaefer2022-11-091-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.
* 50897: nonzero status of complex commands should trigger ERR_EXITBart Schaefer2022-11-081-1/+1
|
* 50851: restore typtab when necessaryJun-ichi Takimoto2022-11-021-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.
* 50136: Fix =(nosuchcommand) race/deadlock first reported in workers/42609Bart Schaefer2022-04-291-4/+0
|
* 50162: Fix multios with current-shell "exec" (aka nullexec).Bart Schaefer2022-04-281-0/+4
|
* 50049: care with signed charactersPeter Stephenson2022-04-251-1/+1
| | | | | Some signed-to-unsigned casts needed for a couple of cases of pointers used as indices.
* 49906 (Bart), 49911: Fixes to querying jobs in subshell.Peter Stephenson2022-03-301-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.
* 49813: <<<: Document newline behavior and fix optimizationMikael Magnusson2022-03-301-1/+3
| | | | | The =(<<<foo) optimization forgot to add a newline, but =(cat<<<foo) always did, make the behavior consistent, and document it.
* 49694 + doc: Allow using empty STTY= to freeze tty for a single commandMikael Magnusson2022-01-301-2/+4
| | | | | Previously, doing this would just run stty with no arguments, which normally causes it to print some terminal settings to stdout.
* github #82: Fix typosDimitris Apostolou2021-11-121-1/+1
|
* 49353: Fix comments in sourced file.Peter Stephenson2021-09-091-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.
* 49307 with doc update: POSIX_TRAPS fix.Peter Stephenson2021-08-261-1/+2
| | | | | With POSIX_TRAPS set, an ignored signal stays ignored when entering a subshell.
* 48857: declare "volatile" all globals that may be modified by signal handlersBart Schaefer2021-05-161-3/+5
|
* 47794: exec: run final pipeline command in a subshell in sh modebrian m. carlson2021-04-101-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.
* Allow more scripts without #!Justine Tunney2021-02-161-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
* 46268: suppress a useless compiler warning around nice()Roman Perepelitsa2020-07-281-2/+1
| | | | | | | From nice(2): To detect an error, set errno to 0 before the call, and check whether it is nonzero after nice() returns -1.
* 46175/0003: Fix the RM_STAR_SILENT bug from the parent commit.Daniel Shahaf2020-07-051-1/+1
|
* 46026: Add CLOBBER_EMPTY option.Peter Stephenson2020-06-091-5/+22
|
* users/24909: Don't clean up special file list too early.Peter Stephenson2020-06-081-1/+1
| | | | | When running a function, remove special files used for substitution after the function has run rather than before.
* 45923 (with memory leak fixed, cf. 45924): zprof: Don't tally all anonymous ↵Daniel Shahaf2020-05-281-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | functions as though they were a single function named "(anon)". Before: % zmodload zsh/zprof % () : % () : % zprof num calls time self name ----------------------------------------------------------------------------------- 1) 2 0.08 0.04 100.00% 0.08 0.04 100.00% (anon) After: % zmodload zsh/zprof % () : % () : % zprof num calls time self name ----------------------------------------------------------------------------------- 1) 1 0.04 0.04 50.45% 0.04 0.04 50.45% (anon) [:3] 2) 1 0.04 0.04 49.55% 0.04 0.04 49.55% (anon) [:2]
* 45583/0008: Add the 'function -T' syntax.Daniel Shahaf2020-03-221-3/+5
| | | | Config/version.mk was bumped in the previous commit.
* 45583/0007: WC_FUNCDEF: Add a placeholder element.Daniel Shahaf2020-03-221-1/+2
|
* 45583/0001: internal: Remove a redundant assignment.Daniel Shahaf2020-03-221-1/+0
| | | | The value is overwritten five lines below, without being read in the interim.
* Merge remote-tracking branch 'origin/master' into 5.9Daniel Shahaf2020-03-071-4/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Test/D02glob.ztst: On the "unreadable directories can be globbed (users/24619, users/24626)" test, resolve conflicts by removing the Cygwin-only skip that has been added in master, since the test is passing on this branch. This effectively reverts workers/45492. See discussion starting in workers/45504. * origin/master: unposted: Remove 'sgi', as that OpenBSD port has been discontinued. 45509: fix typos in B01cd.ztst 45490 (+45495 and a test): refactor rlimits.c github #49: Fix typo: longson should be loongson users/24710: Fix job control problem with sudo. 45492: skip test added by users/24633 on Cygwin 45488: COMP_WORDS for bash need "$@"-style quoting 45487: Missing mod_export declarations for AIX 45447: Complete vcs_info_hookadd and vcs_info_hookdel. Expose _vcs_info_hooks as a top-level helper function. 45463: test: kill: Document why we use SIGURG 45453: builtins: kill: Do not signal current process group when pid is empty 45452: builtins: kill: Add `kill ''` regression test with explicit sigspec 45451: builtins: kill: Add basic test suite github #48/0002: vcs_info git: properly detect bare repositories github #48/0001: vcs_info git: avoid warnings in bare repositories unposted: Post-release version bump unposted: Release 5.8 CVE-2019-20044: Update change log for preceding commits Update NEWS/README Add unsetopt/PRIVILEGED tests Clean up error-message white space Improve PRIVILEGED fixes (again) Improve PRIVILEGED fixes Drop privileges securely unposted: V01zmodload: Fix failing test from workers/45385 45423: _su: Improve arg handling, shell look-ups unposted: _zip: Recognise '--' 45385: Add a test for 'zmodload -Fa' preemptively disabling ("blacklisting"?) features. unposted: Test release: 5.7.1-test-3 zsh/system: Fix infinite loop in sysread _diff_options: Restore -w completion lost in workers/43351 unposted: Fix ChangeLog typo. 45368: Add tests for workers/45367's issue about double slashes in 'cd -P' and /home/daniel/in/zsh. 45373: Fix ERR_EXIT bug in else branch of if. 45372: Record a symlink loop bug involving :P 45365: _git: Fix __git_recent_branches for the case when a commit has an empty message 45343: Queue signals around arithmetic evaluations 45344: Document where third-party completion functions should be installed. 45345: internal: ztst.vim: Fix highlighting of zsh comments in test payload unposted: internal: Add some comments and fix indentation. No functional change. 45340: internal: Document the difference between paramtab and realparamtab. 45332: _git: add completion for git-version _brace_parameter: add missing \ Conflicts: ChangeLog Test/D02glob.ztst Test/V01zmodload.ztst
| * users/24710: Fix job control problem with sudo.Peter Stephenson2020-02-271-1/+2
| | | | | | | | | | | | | | If we use kill to test for continued existence of a process group, we should check on failure that the error is ESRCH, as EPERM indicates the group still has memebers but running privileged so should be left alone.
| * 45343: Queue signals around arithmetic evaluationsDaniel Shahaf2020-01-291-3/+0
| | | | | | | | | | The queueing added in execarith() in 45083 is reverted since the callee does this now.
* | 45131: Make a function that redefines itself preserve its tracedness.Daniel Shahaf2019-12-261-0/+6
|/ | | | | This makes it easy to apply local tracing ('functions -T') to autoloadable functions that redefines themselves when first loaded.
* 45083: Add signal protection to execarith().Peter Stephenson2019-12-181-0/+3
| | | | | Otherwise we could get re-entrancy in memory functions when setting variables.
* 45066: internal: Document forklevel, locallevel, and exit_pending.Daniel Shahaf2019-12-181-0/+4
|