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

1125 commits

Author SHA1 Message Date
Bart Schaefer
f85cb45045 Merge branch 'typesettounset' into declarednull
Adds 'setopt typeset_to_unset', documentation, failure tests for POSIX incompatibilies, etc.
2021-04-13 21:30:06 -07:00
Bart Schaefer
f621fb7ab8 Fix ${(t)var} output, add comparative test cases 2021-04-13 21:18:35 -07:00
Bart Schaefer
dcd4439a9f Missed files from POSXIBUILTINS commit 2021-04-13 21:18:35 -07:00
Bart Schaefer
3099e79d25 Make DECLAREDNULL require POSIXBUILTINS and introduce a new test file.
V10private has been made agnostic to POSIXBUILTINS.
2021-04-13 21:18:35 -07:00
Bart Schaefer
dddae7f055 Add PM_DECLARED and PM_DECLAREDNULL parameter flags.
This addresses the issue that "typeset foo" creates $foo set to an
empty string, which differs from typeset handling in bash and ksh.
It does this by concealing the internal value rather than alter
the way internal values are defaulted.

This imposes the following changes:

A typeset variable with no assignment triggers NO_UNSET warnings
when the name is used in parameter expansion or math.

The typeset -AEFHLRTZailux options are applied upon the first
assignment to the variable.  Explicit unset before the first
assignment discards all of those properties.  If any option is
applied to an existing name, historic behavior is unchanged.

Consequent to the foregoing, the (t) parameter expansion flag
prints nothing until after the first assignment, and the (i)
and (I) subscript flags also print nothing.

The bash behavior of "unset foo; typeset -p foo" is NOT used.
This is called out as an emulation distinction, not a change.

The test cases have not been updated, so several now fail.
The test harness has been updated to declare default values.
2021-04-13 21:18:34 -07:00
Bart Schaefer
fefd3854b4 48487 (amended): Failure test for math evaluation oddity
This was inadvertently included with TYPESET_TO_UNSET, so only the amendment is included here.
2021-04-13 14:22:11 -07:00
Bart Schaefer
6c9a1f5e80 Update descriptive test for POSIX $((inf)) failure 2021-04-12 15:43:23 -07:00
Bart Schaefer
b3613e4895 Change TYPESET_DOES_NOT_SET to TYPESET_TO_UNSET to avoid double-negative 2021-04-12 13:59:06 -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
Bart Schaefer
e67ccd7f1e Add TYPESET_DOES_NOT_SET option (cf. 48469) 2021-04-10 14:13:02 -07:00
Bart Schaefer
d649bf78dc Fix ${(t)var} output, add comparative test cases 2021-04-10 14:12:29 -07:00
Bart Schaefer
2eb9289d12 Missed files from POSXIBUILTINS commit 2021-04-10 14:12:29 -07:00
Bart Schaefer
d4fa4c3689 Make DECLAREDNULL require POSIXBUILTINS and introduce a new test file.
V10private has been made agnostic to POSIXBUILTINS.
2021-04-10 14:12:29 -07:00
Bart Schaefer
36886b5bac Add PM_DECLARED and PM_DECLAREDNULL parameter flags.
This addresses the issue that "typeset foo" creates $foo set to an
empty string, which differs from typeset handling in bash and ksh.
It does this by concealing the internal value rather than alter
the way internal values are defaulted.

This imposes the following changes:

A typeset variable with no assignment triggers NO_UNSET warnings
when the name is used in parameter expansion or math.

The typeset -AEFHLRTZailux options are applied upon the first
assignment to the variable.  Explicit unset before the first
assignment discards all of those properties.  If any option is
applied to an existing name, historic behavior is unchanged.

Consequent to the foregoing, the (t) parameter expansion flag
prints nothing until after the first assignment, and the (i)
and (I) subscript flags also print nothing.

The bash behavior of "unset foo; typeset -p foo" is NOT used.
This is called out as an emulation distinction, not a change.

The test cases have not been updated, so several now fail.
The test harness has been updated to declare default values.
2021-04-10 14:12:29 -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
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
Daniel Shahaf
608e49ac19 48425: Add an XFail test for a 'zstyle -L' escaping bug (workers/48424). 2021-04-07 17:45:57 +00:00
Marlon Richert
aaf619cc22 48413: Fix _expand completion test 2021-04-06 13:59:43 +02:00
Mikael Magnusson
ea3351c496 48202 + 48366: Fix handling of NUL bytes in zexpandtabs multibyte version 2021-04-01 09:50:52 +02:00
Marlon Richert
07a30613f0 48214: add file types to _expand completions, so they can be colored through complist 2021-03-31 01:20:36 +02:00
dana
d3906d7a2f 48216: Fix broken Y01 test from workers/48180 2021-03-28 00:22:59 -05:00
dana
78cf455871 unposted: Improve documentation and add regression test for workers/47745 2021-03-23 00:26:21 -05:00
Marlon Richert
f4a248f9d3 48180: Start menu selection with select=long-list in menu style 2021-03-17 12:50:57 -05:00
Daniel Shahaf
f87b73e677 48147/0002: zmathfunc: Fix bug where the exit code would be non-zero if the expression evaluted to zero. 2021-03-07 21:58:13 +00:00
Daniel Shahaf
6a2a8acf09 48147/0001: tests: Add a unit test for zmathfunc and a regression test for workers/48146 affecting it. 2021-03-07 21:58:12 +00:00
Joshua Krusell
3d6e5b6231 47905: Add leading '-' to zparseopts option parsing errors 2021-02-13 00:54:59 +01:00
Bart Schaefer
465738fc25 47895: Remove trailing spaces from "print -ac" output lines. 2021-02-04 17:52:22 -08:00
Bart Schaefer
b803fbaa14 47865: More tests for globbing in restricted directories 2021-02-04 17:03:46 -08:00
Joshua Krusell
9120d1e841 47899: Improve error message from zparseopts. 2021-02-03 11:33:47 +00:00
Jun-ichi Takimoto
6e20f0e3d1 47849: do not skip tests requiring zpty on Cygwin 2021-01-20 13:49:42 +09:00
Mikael Magnusson
8773f01f2b 47494, 47495: Add -n option to strftime 2020-10-25 23:06:02 +01:00
Mikael Magnusson
ea64d2fd4b 47302: Test for print -v fix 2020-10-25 23:05:28 +01: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
06265d2b83 47314: is-at-least false positive (5.8.0.2 / 5.8)
Actual behaviour:

    % is-at-least 5.8.0.2 5.8 && echo yes || echo no
    yes
    % is-at-least 5.8.0.2 5.8.0.0 && echo yes || echo no
    no

Expected behaviour: Both commands should have printed "no".
2020-08-16 14:24:29 +00:00
Daniel Shahaf
a2a0293d4f 47296 (+ unposted additional tests and comments): 'repeat' loops: Let the repeat count use $?.
It's an arithmetic expression.
2020-08-08 06:11:00 +00:00
Daniel Shahaf
b5f24592ad 46183: New XFail test: external command with =(...) on LHS of pipeline cleans up its tempfiles. 2020-07-12 15:57:49 +00:00
Daniel Shahaf
03407c2928 46204: Fix new test case for the theoretical case of having more than 100 files in the root directory. 2020-07-12 11:37:16 +00:00
Cedric Ware
4d7aa71d8e 46152: zsh/system: Re-allow '0' timeout in zsystem flock 2020-07-11 00:14:58 -05:00
Jun-ichi Takimoto
c04a391877 46215: make the test for RM_STAR_SILENT work on wider systems 2020-07-09 19:06:07 +09:00
Bart Schaefer
126a3158d5 46189: Ignore exit status of final zpty_flush in comptesteval 2020-07-07 09:36:11 -07:00
Daniel Shahaf
cf134c15a0 46175/0003: Fix the RM_STAR_SILENT bug from the parent commit. 2020-07-05 11:11:59 +00:00
Daniel Shahaf
b58141c4cf 46175/0002: Add a regression test for 46169: the RM_STAR_SILENT logic processes the current directory rather than the root directory.
The bug will be fixed in the next commit.
2020-07-05 11:11:59 +00:00
Daniel Shahaf
d1b4e60ff5 46175/0001: Add a unit test for the RM_STAR_SILENT option. 2020-07-05 11:11:59 +00:00
Daniel Shahaf
805b946b53 46174/0002: test harness: Restore indentation after the previous commit. No functional change. 2020-07-05 11:11:22 +00:00
Daniel Shahaf
63fde0b744 46174/0001: test harness: Plug a symlink attack
The test harness created tempfiles with a predictable names and sourced
them without verifying they had been created by itself.  This opened
anyone who ran the test suite to a symlink attacks from other local
users on the build machine.

Fix this by creating the file whilst NO_CLOBBER and ERR_EXIT are both in
scope, to ensure that we'll abort unless the file really was created as
expected.

Put the existing rm(1) call in a try/always block to help it be unlinked
on test failures, thus reducing the chances of the NO_CLOBBER check
triggering on tempfiles created by earlier test suite runs.

I had first tried to fix this by using the
.
    () { ... } =(:)
.
idiom, but couldn't get that to work: it broke the %prep code of X03
with ZTST_verbose unset (its default value) but not with ZTST_verbose=3.
(I tried to set the latter to debug zpty_flush.)

While there, add a needed-in-principle-but-noop-in-this-specific-case (q).

Indentation will be restored in the next commit.
2020-07-05 11:11:22 +00:00
Matthew Martin
4e471c3f89 46168: Update $PWD and call chpwd hook after normalizing path 2020-07-03 21:17:58 -05:00
Peter Stephenson
4e0058afc5 users/24971: ${(-)var} sorts on signed integers 2020-07-03 21:05:46 +01:00
Daniel Shahaf
0cffb0a6b3 46072 + 46136: Add the 'zle $widget -f nolast' syntax, to improve add-zle-hook-widget support for multiple hook functions.
See workers/46004 for the use-case.
2020-06-27 03:09:31 +00:00
Peter Stephenson
7865486994 46100: Fix =subst before =(subst)
This occurs with SH file expansion ordering.

Add test.
2020-06-26 17:32:02 +01:00