1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-23 17:01:05 +02:00
Commit graph

448 commits

Author SHA1 Message Date
Philippe Altherr
4616ea398a 53005: off-by-one error when resetting signals on subshell entrance 2024-08-04 19:12:32 -07:00
Jun-ichi Takimoto
2a54de1675 52985: avoid adding original param to restorelist 2024-07-04 11:51:09 +09:00
Philippe Altherr
da733f5df6 52977: ERR_EXIT/ERR_RETURN are respected by the final command in && / || lists 2024-06-28 21:05:42 -07:00
Oliver Kiddle
57248b8883 52750: remove ansi2knr support for old pre-ansi K&R compilers 2024-03-18 20:02:34 +01:00
Bart Schaefer
610b18875a 52650 plus minor fixes: add -u for named references pointing to "upper" scope 2024-03-04 21:07:01 -08:00
Oliver Kiddle
5331ff11c6 52594: support for POSIX real-time signals with kill and trap
Also add new -L option to kill for a more verbose listing of signals
2024-02-28 00:21:11 +01:00
Bart Schaefer
b68002d927 Fix META_NOALLOC to META_STATIC in 'bad interpreter' metafy 2024-02-24 21:28:35 -08:00
Bart Schaefer
69c0c646bb 52596: metafy interpreter name for error message 2024-02-24 20:45:29 -08:00
Stephane Chazelas
f1e7481b86 45837: fix process group restoration upon exit 2024-02-18 18:56:39 +00:00
Stephane Chazelas
b3cad1c24c 52515: (+ tests in 52527) avoid sh errors when running shebang-less scripts with paths starting with - or + 2024-02-18 18:22:37 +00:00
Bart Schaefer
fcf080ab57 52313: Src/exec.c: multios are not interactive and check for write errors. 2023-11-18 16:22:24 -08:00
Bart Schaefer
ddfc81a2b8 52309: fix cases that hang with all signals blocked.
* no job control inside <<(substition)
* allow interrupt of multios reading from a terminal
2023-11-15 20:29:50 -08:00
ErrrorMaxx
0c15cc8712 github #104: fix small typo 2023-10-24 20:42:46 -05:00
Bart Schaefer
96ce0abf6b 52125: getoutput() must not free() after gettempname(..., 1) for heap 2023-09-10 21:00:23 -07:00
Peter Stephenson
8f5fe841a6 51652: fix running of TRAPEXIT explicitly.
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-17 09:30:34 +01:00
Jun-ichi Takimoto
98b4d4bdca 51632: nmetafy $_ when exporting it to child 2023-04-09 20:33:32 +09:00
Peter Stephenson
12e5db145b 51608: Don't execute commands after "continue &&"
Also ! continue ||
2023-03-29 10:52:05 +01:00
Peter Stephenson
7e0c4406ce 51424: $(<...) shouldn't try to open a file with NO_EXEC 2023-02-14 09:21:32 +00:00
Oliver Kiddle
a73c705b0c 51212: remove STOUC() macro
This served as a workaround for ancient compilers where casts to
unsigned char were broken.
2022-12-16 23:28:10 +01:00
Bart Schaefer
6d49734d46 51210: Clear errflag before calling EXIT trap
If this is not done, special cases such as failures in special builtins
or errors in math expressions skip the trap execution.
2022-12-13 21:11:33 -08:00
Peter Stephenson
67d4bf5bb9 51134: ! return doesn't change the return status 2022-12-12 10:30:13 +00:00
Bart Schaefer
2028539cb1 51161: correct errno after closing xtrace FD 2022-12-09 19:30:35 -08:00
Philippe Altherr
8086f10615 51094: consistent use of bit-manipulation for noerrexit value changes 2022-12-03 21:46:42 -08:00
Philippe Altherr
ab9c579ef9 51098: remove unreachable NOERREXIT_UNTIL_EXEC code and effects 2022-12-03 21:35:51 -08:00
Philippe Altherr
f253ea6b9d 51076: fix ERR_EXIT when used with "eval" or "source"; documentary comments 2022-12-03 21:14:26 -08:00
Philippe Altherr
259f1e944b 51071: fix ERR_RETURN for functions in conditional statements 2022-12-03 21:03:36 -08:00
Philippe Altherr
dd3ba3d599 51001: fix for ERR_EXIT following shell function; update tests 2022-12-03 20:44:10 -08:00
Philippe Altherr
d47b8480f0 51001: fix for ERR_EXIT with pipeline negation ("!"); update tests 2022-12-03 20:42:13 -08:00
Philippe Altherr
23dc19f005 51001: Reverts 8839e969b, most of 1ba8714a, and d873ed60.
Also correct ChangeLog
2022-12-03 20:31:42 -08:00
Bart Schaefer
8839e969bf 50929: fix handling of ERR_RETURN bent by 50928. 2022-11-09 21:48:46 -08:00
Bart Schaefer
1ba8714a7a 50928: fix tests for 50897, mention behavior change in NEWS 2022-11-09 21:37:56 -08:00
Bart Schaefer
61610ea4bd 50922: fix additional cases of signals for current shell jobs on the right 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-09 20:24:57 -08:00
Bart Schaefer
d873ed6026 50897: nonzero status of complex commands should trigger ERR_EXIT 2022-11-08 20:36:49 -08:00
Jun-ichi Takimoto
f8d93888a8 50851: restore typtab when necessary
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-11-02 16:27:27 +09:00
Bart Schaefer
8181708feb 50136: Fix =(nosuchcommand) race/deadlock first reported in workers/42609 2022-04-29 20:37:09 -07:00
Bart Schaefer
0ccc3c1494 50162: Fix multios with current-shell "exec" (aka nullexec). 2022-04-28 17:03:31 -07:00
Peter Stephenson
c5a891a29d 50049: care with signed characters
Some signed-to-unsigned casts needed for a couple of cases of pointers
used as indices.
2022-04-25 17:51:59 +01:00
Peter Stephenson
98e4634086 49906 (Bart), 49911: Fixes to querying jobs in subshell.
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-30 09:28:43 +01:00
Mikael Magnusson
d7b8619396 49813: <<<: Document newline behavior and fix optimization
The =(<<<foo) optimization forgot to add a newline, but =(cat<<<foo)
always did, make the behavior consistent, and document it.
2022-03-30 08:07:39 +02:00
Mikael Magnusson
8bf0f0cf45 49694 + doc: Allow using empty STTY= to freeze tty for a single command
Previously, doing this would just run stty with no arguments, which
normally causes it to print some terminal settings to stdout.
2022-01-30 18:14:54 +01:00
Dimitris Apostolou
356dcb20ce github #82: Fix typos 2021-11-12 23:54:34 +01:00
Peter Stephenson
db46c9cd58 49353: Fix comments in sourced file.
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-09-09 20:05:39 +01:00
Peter Stephenson
0a80579ed1 49307 with doc update: POSIX_TRAPS fix.
With POSIX_TRAPS set, an ignored signal stays ignored when entering
a subshell.
2021-08-26 09:46:39 +01:00
Bart Schaefer
cf5c4828d1 48857: declare "volatile" all globals that may be modified by signal handlers 2021-05-16 19:51:11 -07:00
brian m. carlson
f7a417388c 47794: exec: run final pipeline command in a subshell in sh mode
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-04-10 17:56:39 -05:00
Justine Tunney
326d9c203b Allow more scripts without #!
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] 9a1cd36331
[2] http://austingroupbugs.net/view.php?id=1250
[3] http://austingroupbugs.net/view.php?id=1226#c4394
[4] https://justine.lol/cosmopolitan/index.html
2021-02-16 09:16:20 +00:00
Roman Perepelitsa
41e318727e 46268: suppress a useless compiler warning around nice()
From nice(2):

    To detect an error, set errno to 0 before the call, and check
    whether it is nonzero after nice() returns -1.
2020-07-28 11:46:14 +02:00
Daniel Shahaf
cf134c15a0 46175/0003: Fix the RM_STAR_SILENT bug from the parent commit. 2020-07-05 11:11:59 +00:00
Peter Stephenson
3df604a4be 46026: Add CLOBBER_EMPTY option. 2020-06-09 18:07:01 +01:00
Peter Stephenson
d7e90f1c7c users/24909: Don't clean up special file list too early.
When running a function, remove special files used for substitution
after the function has run rather than before.
2020-06-08 20:52:53 +01:00