1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-04 10:41:11 +02:00
Commit graph

4050 commits

Author SHA1 Message Date
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
Peter Stephenson
4a9437317f 49297 (quoting amended): error message in files module.
If ENONENT it could be the other argument that doesn't exist, so check.
2021-08-24 19:21:53 +01:00
Peter Stephenson
daa208e907 49269: Fix "[ ! -o ]".
This should detect "-o" as non-empty string; "-a" was alrady working.
Update the test.
2021-08-10 09:19:32 +01:00
Erik Paulson
f8ec33c453 49029: Prevent shell from sending duplicate signals with MONITOR 2021-07-23 21:08:13 +01:00
Peter Stephenson
50dc7f2913 49182: Turn off correction inside command substition.
In "A=$(PWD)" we dont't have the information to correct at the level of the
PWD subcommand, so don't try to do it as this causes a crash.
2021-07-23 20:27:38 +01:00
Jun-ichi Takimoto
9b3a292410 49166: fix coredump in ${name:offset:length} with ill-formatted length 2021-07-19 09:13:03 +09:00
Peter Stephenson
d293c12de6 49102: Ignore dynamic directory name failure if NO_EXEC 2021-06-28 15:42:01 +01:00
Bart Schaefer
5b4a1626c2 49069: literal interpretation of subscripts for unset of array/hash elements 2021-06-13 16:30:06 -07:00
Oliver Kiddle
978c4907b6 48954: avoid crash in reverse-menu-complete from menuselect without 'menu' in $compstate[insert] 2021-06-03 00:22:37 +02:00
Bart Schaefer
cf5c4828d1 48857: declare "volatile" all globals that may be modified by signal handlers 2021-05-16 19:51:11 -07:00
Han Pingtian
8bdbc61497 33465: use prctl() for "jobs -Z" where available
Bart apologizes for waiting 7 years to apply this change.
2021-05-15 14:23:28 -07:00
Vincent Lefevre
4fa4dcad17 48723: locale-safe recognition of "Inf" and "NaN" constants in math 2021-05-15 14:11:49 -07:00
Peter Stephenson
db36149006 users/26742: break out of surrounding shell loops when exit is called from an exit hook 2021-05-15 13:59:17 -07:00
Bart Schaefer
e4bd6dc818 users/26736: avoid infinite loop in getbyte from exit hook 2021-05-15 13:51:39 -07:00
Bart Schaefer
d0e071c5f0 48790: COMPLETE_IN_WORD inside brace-param 2021-05-15 13:40:37 -07:00
Peter Stephenson
9e38ab8178 48787: Fix command status after failed if
If "if" had a hard error in the condition, and there was no
else clause, the command status was incorrectly cleared to zero.

Add test.
2021-05-06 10:03:27 +01:00
dana
c23a0d84b0 48614: getopts: Calculate OPTIND according to POSIX_BUILTINS 2021-05-03 18:11:38 -05:00
Bart Schaefer
71b747567e 47704: POSIX export and readonly ignore "-p" when parameter names also appear 2021-04-18 14:26:12 -07:00
Bart Schaefer
82ff9f24f1 48560: add TYPESET_TO_UNSET option to remove initialization of parameters
Changes typeset such that ${newparam-notset} yields "notset" and
"typeset -p newparam" does not show an assignment to the parameter.  This
is similar to the default behavior of bash and ksh, with minor differences
in typeset output.

Also add tests for some POSIX incompatibilities plus minor changes for test
harness robustness.
2021-04-18 13:58:09 -07:00
Jun-ichi Takimoto
a90d5ab901 48439: remove macros that became unnecessary by df48cc8 2021-04-12 14:42:29 +09:00
Oliver Kiddle
704d10989e 48504: use SEEK_ macros in fseek() calls 2021-04-11 22:26:36 +02:00
Michael Stapelberg
6388156233 45396: readhistfile: avoid thousands of lseek(2) syscalls via ftell() 2021-04-11 21:38:27 +02: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
Bart Schaefer
408a830483 47913: implement CASE_PATHS option to make NO_CASE_GLOB more sensible 2021-04-10 14:26:46 -07:00
Peter Stephenson
283d2f3c27 48432 and enable test: fix quotiing of zstyle -L for zstyle -e 2021-04-09 21:01:37 +01:00
Felipe Contreras
df48cc8404 47785: remove deprecated autoconf functions
STDC_HEADERS and TIME_WITH_SYS_TIME are deprecated.
2021-04-09 21:45:11 +02:00
Daniel Shahaf
4ba9008ec7 48379: Make the parameter expansion subscript flags parse error message, "error in flags", identify the location of the parse error. 2021-04-08 02:19:39 +00:00
Jun-ichi Takimoto
9562a1ee7b 48391: fix display problem in menu-complete
Take account of the trailing file type character even when '-d disp'
is given to compadd.
2021-04-06 23:38:52 +09:00
Jun-ichi Takimoto
0f62e07c80 48389: getkeystring() should not return ptr to local var
Now it returns NULL if called with GETKEY_SINGLE_CHAR and next character
is not found. Caller must check the return value.
2021-04-06 23:05:03 +09:00
Felipe Contreras
94b5446838 47784: silence a compiler waring from pattern.c 2021-04-04 14:48:01 +09:00
Oliver Kiddle
0721060f36 47510: drop code that avoided termcap for named colours
The inconsistency caused test failures where TERM is e.g. rxvt-unicode.
This also makes a couple of bits available in zattr by removing flags
indicating whether to use termcap which is not an attribute as such.
2021-04-03 00:58:45 +02:00
Mikael Magnusson
ea3351c496 48202 + 48366: Fix handling of NUL bytes in zexpandtabs multibyte version 2021-04-01 09:50:52 +02:00
Stephane Chazelas
d96c898101 47745: Fix [:IDENT:] vs posixidentifiers
wcsitype(c, IIDENT) should return false for non-ASCII characters
when the POSIX_IDENTIFIERS option is on, not the other way round.
2021-03-23 00:15:09 -05:00
Peter Stephenson
6bef719302 users/26509: fix for r -L
fc with the -L option should ignore remote entires, rather than
reading them and treating them as an error.
2021-02-18 21:37:08 +00:00
Martijn Dekker
9c0533931c 48073: Add fc -s as POSIX way of rerunning command without starting editor 2021-02-17 10:21:08 +00: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
Joshua Krusell
3d6e5b6231 47905: Add leading '-' to zparseopts option parsing errors 2021-02-13 00:54:59 +01:00
Bart Schaefer
2cf6032a30 47997: Disable XTRACE around user-defined completion widgets. 2021-02-11 19:13:47 -08:00
Bart Schaefer
465738fc25 47895: Remove trailing spaces from "print -ac" output lines. 2021-02-04 17:52:22 -08:00
Joshua Krusell
9120d1e841 47899: Improve error message from zparseopts. 2021-02-03 11:33:47 +00:00
GammaFunction
5d14b6eb71 47744: Fix vi repeats with hooks in use. 2021-01-27 10:04:40 +00:00
Peiyuan Song
bf8ca5f019 47840: make zpty module work on Cygwin 2021-01-20 13:33:52 +09:00
Bart Schaefer
3499a676fa 47704: fix scope for "private -p" 2020-12-02 20:14:45 -08:00
Mikael Magnusson
8773f01f2b 47494, 47495: Add -n option to strftime 2020-10-25 23:06:02 +01:00
Jun-ichi Takimoto
b6ba74cd4e 47301: Fix print -v metafication 2020-10-25 23:05:19 +01:00
Roman Perepelitsa
ead29c2a36 Fix a race condition in zf_mkdir -p
If ~/foo does not exist and `zf_mkdir -p zf_mkdir -p` is executed
concurrently in multiple shells, it was possible prior to this patch
for the command to fail with EEXIST.
2020-10-23 11:42:30 +02:00
Bart Schaefer
04bd9a44a7 Unposted - fix comment 2020-09-13 17:13:51 -07:00
Bart Schaefer
63b6398b70 47364: Enable extendedglob in pattern with ${(*)name/pattern/replacement}
Mikael Magnusson: 47382: Completion for 47364
2020-09-13 16:19:52 -07:00
Stephane Chazelas
24a82b9dad 47352 (+ extra test cases): fix %<n>K prompt expansion
Fixed a regression introduced by workers/30496 (5.0.3) whereby %2K would
no longer be the equivalent of %K{2} (%K{green}) in prompt expansion.

That was one missing case where the is_fg flag was not passed along to
match_colour() after code factorisation.

Add tests for the different syntax variants, using echoti
as a reference.
2020-09-10 07:34:56 +01:00
Daniel Shahaf
c6a8516361 github #64: Fix a build-time error when building against ncurses that hadn't been built with --enable-wgetch-events.
The --enable-wgetch-events codepath is experimental (according to
ncurses-6.2/INSTALL) and off by default (according to
ncurses-6.2/configure.in).  With that codepath disabled, the macro
KEY_EVENT is not provided, which (before this commit) manifested as a
build-time error:

    [  245s] gcc -c -I. -I../../Src -I../../Src -I../../Src/Zle -I.  -DHAVE_CONFIG_H -DMODULE -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fPIE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/ncursesw -fPIC -o curses..o curses.c
    [  246s] In file included from curses.c:210:
    [  246s] curses_keys.h:93:15: error: 'KEY_EVENT' undeclared here (not in a function); did you mean 'KEY_RESET'?
    [  246s]    93 |     {"EVENT", KEY_EVENT},
    [  246s]       |               ^~~~~~~~~
    [  246s]       |               KEY_RESET

curses_keys.h is only used for setting the "kevent" output parameter of
'zcurses input' (and the associated $zcurses_keycodes special variable),
so there's no harm in just leaving KEY_EVENT out of it.  (That codepath
deals gracefully with numeric values that don't correspond to any of the
known compile-time values, as that can happen whenever the build- and
run-time versions of ncurses don't provide the same set of KEY_* macros,
with or without relation to that configure flag.)

Reported by Martin Liska.
2020-08-28 02:54:51 +00:00