1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-27 06:22:20 +02:00
Commit Graph

1231 Commits

Author SHA1 Message Date
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
oxiedi
c4540e154f 45895: ignore deduplication patterns in _sequence 2020-06-26 00:34:33 +02:00
Daniel Shahaf
dd6e702ee4 46068 (tweaked) (was: github #57): region_highlight: Add memo= support.
This is useful when multiple plugins add region_highlight entries and
subsequently want to remove only their own entries.  Without this
functionality, recognizing one's region_highlight entries is not trivial
because the 'start' and 'end' offsets are modified by editing of $BUFFER
and the highlight specification may not be unique or distinctive.

The tweaks are as follows:

- Change zfree() to zsfree() per workers/46070.

- Remove the mem.c hunk, as it changed the signature of only one out of
  two alternative definitions of zsfree().  (The definition that hunk
  touched is the one that's not used by default.)
2020-06-25 11:50:33 +00:00
Daniel Shahaf
304ce85a2a 46102: test harness: Make the XPass message distinct from the Fail message.
The new output is:

    ./Test/B02typeset.ztst: starting.
    Test ./Test/B02typeset.ztst was expected to fail, but passed.
    Was testing: this is the description that's after the colon on in the ztst file
    ./Test/B02typeset.ztst: test XPassed.
    **************************************
    0 successful test scripts, 1 failure, 0 skipped
    **************************************
    make[1]: *** [Makefile:190: check] Error 1
    make: *** [Makefile:263: check] Error 2

The new function is deliberately very similar to ZTST_testfailed() just
above it.
2020-06-25 10:24:11 +00:00
Peter Stephenson
af1c009c3e 46079: Ignore double quotes in math expressions.
Treat as white space.

This is required for compatibility and previously had no use in zsh
as it generated an error.
2020-06-23 12:17:32 +01:00
Daniel Shahaf
6be112fe74 46067: Add a unit test for workers/46060. 2020-06-18 10:34:11 +00:00
Peter Stephenson
3df604a4be 46026: Add CLOBBER_EMPTY option. 2020-06-09 18:07:01 +01:00
Peter Stephenson
40723b3991 45900: Fix issues with escaped newline in $-substitution. 2020-05-23 18:01:26 +01:00
Daniel Shahaf
c7da34dd71 45862: Add test cases for 45843#1 and 45843#2, adapted from Aaron Esau and pws. 2020-05-20 00:48:41 +00:00
Mikael Magnusson
06c0a39895 unposted: Add tests for previous commit 2020-05-12 15:58:41 +02:00
Daniel Shahaf
ab835f0c37 45764: Add a regression test for 45772. Test by Roman 2020-05-05 21:15:54 +00:00
Daniel Shahaf
deca7c9285 45730: _arguments: Add the -0 flag, which makes $opt_args be populated sanely.
Also, write/extend docstrings for sepjoin() and zjoin().
2020-05-03 01:27:36 +00:00
Daniel Shahaf
34d69acbef 45737 (+ docs, and update the test from 45722): zstyle: When determining the weight (specificity) of a pattern, consider the number of components before anything else, as documented. 2020-05-02 01:12:07 +00:00
Daniel Shahaf
95adde8ddc unposted: Revert unintentional move from 45722. 2020-05-02 00:55:52 +00:00
Daniel Shahaf
5d9f7975a9 45722: docs: Change zstyle example to a non-hierarchical one 2020-05-02 00:51:26 +00:00
Cedric Ware
25c9b61a66 45708: zsh/system: Enable sub-second timeout in zsystem flock 2020-04-20 12:10:01 -05:00
Mikael Magnusson
8923d2a618 Add SHORT_REPEAT option 2020-04-02 07:42:16 +02:00
Daniel Shahaf
c57d660764 unposted: Make test platform-independent.
Follow-up to the grandparent commit.
2020-04-02 00:10:42 +00:00
dana
2bfe01df6f 45542: P01privileged: Use test-directory owner for auto-determined EUID/EGID
Prevents failure when the repo (or its parent) has mode 0700
2020-04-01 17:05:26 -05:00
dana
9818ddeefb unposted: D02glob: Fix platform-dependent test failure
workers/45583 introduced a test failure on macOS, *BSD, and Solaris, where wc
always outputs leading white space
2020-04-01 16:59:32 -05:00
Daniel Shahaf
5e55e3eaf8 unposted: Fix syntax error introduced in 45591. 2020-03-28 00:56:22 +00:00
Daniel Shahaf
5e3f6b60e8 45640: Fix new test when ${PWD}'s value contains symlinks. 2020-03-28 00:46:51 +00:00
Daniel Shahaf
c4f18c29c7 45584, 45620: zsh/rlimits: Skip the tests for this module when it wasn't compiled in. 2020-03-27 01:14:42 +00:00
Daniel Shahaf
32c4ed3977 45591 (Cf. 45587, 45620): In the test suite, centralize testing that compiled modules can be loaded successfully.
Have V01zmodload.ztst check that all modules enabled in config.modules
load successfully.  With this change, the test files for individual
modules may assume that if 'zmodload' fails that must be because the
module hadn't been compiled in, and mark themselves as skipped in that
case.
2020-03-27 01:14:42 +00:00
Peter Stephenson
2a9674862e 45616: Remove token from count argument to repeat 2020-03-26 20:54:37 +00:00
Daniel Shahaf
fc286a7c11 45583/0008: Extend tests to prove that what remains of xsymlinks() handles symlink loops gracefully. 2020-03-25 23:49:02 +00:00
Daniel Shahaf
db8d16a060 45583/0005: Add a test for bin_whence's symlinks resolution. 2020-03-25 23:49:02 +00:00
Daniel Shahaf
47fc5fe01f 45583/0004: Fix segfault on resolving symlink loops 2020-03-25 23:49:02 +00:00
Daniel Shahaf
de587b43ba 45583/0001: Add tests for the segfault on resolving a symlink loop bug (workers/45282).
This is workers/45377, extended.
2020-03-25 23:49:01 +00:00
Daniel Shahaf
0903ddb7b9 45590/0002 (in part): zsh/rlimits: Test that ulimit letters are unique. 2020-03-25 22:06:47 +00:00
Jun-ichi Takimoto
88484e9ea8 45601: fix another status in new function -T test 2020-03-25 15:55:19 +09:00
Peter Stephenson
508b47c750 45601: Fix status in new functions -T test 2020-03-22 18:56:06 +00:00
Daniel Shahaf
aed0cb4408 45583/0009: Add end-of-options guard support to 'function -T'. 2020-03-22 02:23:53 +00:00
Daniel Shahaf
386d9ac8ff 45583/0008: Add the 'function -T' syntax.
Config/version.mk was bumped in the previous commit.
2020-03-22 02:23:53 +00:00
dana
778f391a3b 45537 (tweaked): E02xtrace: Fix inconsistent function-name encoding in preserves-xtrace test
Tweaked per workers/45550, needs workers/45536 to be effective
2020-03-13 08:49:57 -05:00
dana
80ddc46e54 45470: C02cond: Simplify '-N cond' test
This fixes an (intermittent?) issue with the test on macOS+APFS, and hopefully
makes it simpler and faster in general
2020-03-11 21:17:12 -05:00
Daniel Shahaf
1602016d53 45518 + unposted tweak (change single quotes to double quotes): Fix V01zmotload.ztst test failures when zsh/parameter is dynamically linked (which is the default). 2020-03-09 01:56:26 +00:00
Daniel Shahaf
6fc8e8628f Merge remote-tracking branch 'origin/master' into 5.9
* 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
2020-03-07 21:36:46 +00:00
Daniel Shahaf
0d3d07c56f unposted: Fix trailing whitespace in test expectations. 2020-03-07 21:32:57 +00:00
Jun-ichi Takimoto
dd85abe825 45509: fix typos in B01cd.ztst 2020-03-06 20:14:21 +09:00
Jun-ichi Takimoto
273da6cc5f 45490 (+45495 and a test): refactor rlimits.c
Use a table of known resouces instead of generating rlimits.h by
rlimits.awk.
2020-03-06 20:12:06 +09:00
Jun-ichi Takimoto
fe516fccb4 45492: skip test added by users/24633 on Cygwin 2020-02-27 16:08:13 +09:00
Chris Down
69c247de2f 45463: test: kill: Document why we use SIGURG
See discussion in workers/45460.
2020-02-18 19:35:18 +00:00
Chris Down
5c55b3fb50 45453: builtins: kill: Do not signal current process group when pid is empty
The following case was encountered in the wild:

    % zsh; echo "$?"
    % trap 'exit 5' TERM
    % kill ''
    5

This behaviour seems more likely to be the result of bugs in programs
(e.g. `kill -9 "$unsetvar") rather than being desirable
behaviour to me.  It also seems unintentional judging by the code and
documentation, since it comes about as a result of the fact that:

- `isanum` returns true for empty strings (since an empty string
  technically only consists of digits and minuses...);
- `atoi`, when passed a pointer to an invalid number, returns 0;
- `kill(0, signal)` sends the signal in question to all processes in the
  current process group.

There are (at least) two ways to solve this issue:

1. Add special handling to `kill` to avoid this case. See this patch[0]
   for a version that does that.
2. Change how isanum behaves. Since the only two call sites that use it
   both seem like they should handle the case where the input char array
   is empty, that seems like a reasonable overall change to me.[1]

After this patch:

    % trap 'exit 5' TERM
    % kill ''
    kill: illegal pid:

The regression test for `kill` without a sigspec is also included in
this commit, as previously it's not possible to test it trivially as it
would still kill the test runner in expected-to-fail mode; see
discussion in workers/45449.

0: workers/45426: https://www.zsh.org/mla/workers/2020/msg00251.html
1: The other call site using isanum() is the fg builtin, but in that
   case we just fail later since we can't find any job named '', so no
   big deal either way. It's the kill case which is more concerning.
2020-02-18 12:59:53 +00:00
Chris Down
59258252b5 45452: builtins: kill: Add kill '' regression test with explicit sigspec
The version without a sigspec can't be added yet because it would still
kill the test runner even in expected-to-fail mode; see workers/45449
for discussion. For the same reason, we use a signal which is non-fatal
by default and unlikely to be sent by someone else, SIGURG, to do the
expected-to-fail case prior to the fix.
2020-02-18 12:59:52 +00:00
Chris Down
cb5d8bfe86 45451: builtins: kill: Add basic test suite
This is not totally comprehensive, but at least it's a start for the
core functionality. In the next commits, we'll also use this base to add
some regression tests.
2020-02-18 12:59:51 +00:00
dana
b15bd4aa59 Add unsetopt/PRIVILEGED tests 2020-02-14 16:06:58 -06:00
Daniel Shahaf
8250c5c168 Improve PRIVILEGED fixes
- Fix retval handling in bin_setopt()

- Don't skip_setuid / skip_setgid.  It's not our place to optimize away noops
  (that might not even _be_ noops; they might change the saved uid…).

- Remove HAVE_* guard checks around functions that are used unguarded elsewhere.

- Use bsd-setres_id.c from OpenSSH to provide setresuid() / setresgid()
  everywhere, and thus simplify the ifdef soup.  Fix some preëxisting
  bugs in the macro definitions of setuid() (do we still need that one?).

- Fix zwarning() format codes for variadic arguments type safety

- Restored a comment from HEAD

- Fix failure modes around initgroups()

- Compared privilege restoration code with OpenSSH's permanently_drop_uid() and
  updated as needed

- Add E01 PRIVILEGED sanity checks
2020-02-14 16:06:57 -06:00
dana
e89060a377 unposted: V01zmodload: Fix failing test from workers/45385 2020-02-14 15:55:52 -06:00
Daniel Shahaf
699dfdd0ea 45385: Add a test for 'zmodload -Fa' preemptively disabling ("blacklisting"?) features. 2020-02-07 12:44:53 +00:00
Daniel Shahaf
3bcf9641eb 45368: Add tests for workers/45367's issue about double slashes in 'cd -P' and /home/daniel/in/zsh. 2020-02-03 07:09:30 +00:00
Peter Stephenson
e01223a26c 45373: Fix ERR_EXIT bug in else branch of if.
The flags need resetting for this branch otherwise e.g. command
substitution with non-zero status doesn't cause exit.
2020-02-02 18:05:47 +00:00
Daniel Shahaf
b4996ea5eb 45342: Add tests for interaction between autoloadable parameters and module loading. 2020-01-29 08:30:47 +00:00
Daniel Shahaf
7ca2b06501 45304: Do execute the always block even when the try/always block itself is the last command.
Fixes the test added in the previous commit (workers/45305).
2020-01-16 18:29:13 +00:00
Daniel Shahaf
fb3865514c Merge branch 'master' into 5.9
* master:
  45305: Add an XFail test: The exec-last-command optimization is applied to try/always.
  45307: zstyle docs: Unoverload a placeholder variable name.
  45306: zstyle docs: Introduce the first synopsis in the same way as all others: with an item()().
  unposted: docs: Fix a cross-reference.
2020-01-16 18:21:41 +00:00
Daniel Shahaf
28e11ac60b 45305: Add an XFail test: The exec-last-command optimization is applied to try/always. 2020-01-16 18:21:11 +00:00
dana
977e1c75d8 45292: D02glob: Add regression test for macOS stat(2) misbehaviour
On macOS, a privileged stat(2) call can erroneously treat files as
directories, which can produce unexpected glob results. This was reported at
workers/42891. A side-effect of the change from workers/45291 is that it seems
to work around this issue, at least in the obvious cases
2020-01-15 19:31:16 -06:00
Daniel Shahaf
edc04bd946 45291: A glob with a trailing slash will now match unreadable/unexecutable directories. 2020-01-15 19:20:33 -06:00
Daniel Shahaf
e899c21863 Merge remote-tracking branch 'origin/master' into 5.9
Right now, as we're preparing to tag the 5.8 release, the 5.9 branch is
maintained as a topic branch off master.

* origin/master:
  45287: zshexpn: Describe parameter elision and add some introductory prose
  45302: bin_umask(): Queue signals around umask().
  users/24656: docs: Add an example of setting and querying zstyles
  users/24659: Cross-ref doc for matchers.
  45296: D02glob: Clean up after test from users/24633
  45290: New helper script for listing XFail tests.
  users/24633: Add an xfail test for users/24619.
  unposted: additional typo fix
  45280: _git: add -local variants
  users/24628 (fixed): More doc for selectw-word-style widgets.
  45266: Fix losetup completion, broken in da085b7a20 (41720).
  unposted: Fix punctuation.
  use /dev/fd on Cygwin for process substitution
  unposted: Two additional typo fixes.
  Fix typos reported by codespell in shell code
  Fix typos reported by codespell in Src/
  45269: Fix misspellings in completions and elsewhere.
  45261: _gcc: Detect clang-as-gcc
  unposted: internal: Remove Vim modeline that interferes with ztst.vim.
  unposted: internal: ztst.vim: Use :syn-sync to work around (#x) and "`\\\\\\\\`" confusing the highlighting.
  unposted: internal: zyodl.vim: Support glob qualifiers in example()'s
  unposted: internal: zyodl.vim: Support yodl comments.
  github #44: Allow completion for picocom to list symlinks to character devices
  45245: _gcc: add some clang specific warnings
  45231: _rsync: When completing remote modules, ignore more of the motd.
  unposted: _tac: Eliminate superfluous variable
  45226: _man: Improve completion of file paths
  45184: Clarify documentation of %-sequences understood by compadd -[Xx]
  45239: Remove 'appendhistory' from zsh-newuser-install
  45218: add more options to swaks completion
  45196: fix completion after make -C, allowing for -C being used multiple times
  unposted (after 45183): Fix yodl error: "contrib.yo:4457: No macro: back(...)".
  45181: Fix workers/45164: ${(S)%%} will now consider the empty string as a potential match.
  45183: Improve documentation examples
  unposted: Add some tests for ${(S)}, including a regression test for workers/45164.
  45169/0002 (tweaked for trailing newlines): Add an expected-to-fail test for workers/44007.
  45169/0001: In the test suite, allow test cases to be marked as expected to fail.
  users/24582 + users/24583: Add regression tests for the previous commit.
  24581: Fix array assignments in shell word splitting and completion.
  45160: zshexpn: Expand documentation of (S)
  45150 + 45152: zshexpn: Use a more minimal example in the documentation of (#b).
  unposted: internal: Vim ztst support: Add an ftplugin in addition to the syntax highlighter.
  45130: _multi_parts: Always pass -f to compadd if given by caller
  unposted: zerrmsg(): Fix macro guard missed in previous commit
  unposted: ChangeLog for last commit
  internal: Allow %L in zerrmsg() in non-debug builds, too.
2020-01-15 22:49:09 +00:00
dana
62a1e37ccc 45296: D02glob: Clean up after test from users/24633 2020-01-13 17:43:51 -06:00
Daniel Shahaf
9f8c369ccd 45290: New helper script for listing XFail tests. 2020-01-13 22:48:55 +00:00
Daniel Shahaf
0681be600c users/24633: Add an xfail test for users/24619. 2020-01-12 22:14:10 +00:00
Jens Schleusener
11dbe4c286 45269: Fix misspellings in completions and elsewhere. 2020-01-09 13:42:02 +00:00
Daniel Shahaf
379d7088d6 unposted: internal: Remove Vim modeline that interferes with ztst.vim.
As an alternative, one can use:

    autocmd BufRead,BufNewFile **/*.ztst setfiletype zsh

(But see Util/ztst-syntax.vim and Util/ztst-ftplugin.vim for an alternative.)
2020-01-07 19:37:41 +00:00
Daniel Shahaf
b591d43113 45181: Fix workers/45164: ${(S)%%} will now consider the empty string as a potential match. 2020-01-02 16:00:11 +00:00
Daniel Shahaf
ac964897f4 unposted: Add some tests for ${(S)}, including a regression test for workers/45164. 2020-01-01 13:56:04 +00:00
Daniel Shahaf
9432d9b1cf 45169/0002 (tweaked for trailing newlines): Add an expected-to-fail test for workers/44007. 2020-01-01 13:55:39 +00:00
Daniel Shahaf
7e2c80fcd5 45169/0001: In the test suite, allow test cases to be marked as expected to fail.
See next commit for a use-case.
2020-01-01 13:55:39 +00:00
Daniel Shahaf
6a67d38e96 users/24582 + users/24583: Add regression tests for the previous commit. 2019-12-31 18:43:26 +00:00
Daniel Shahaf
4a2a15d8dc unposted: internal: Vim ztst support: Add an ftplugin in addition to the syntax highlighter. 2019-12-27 06:11:28 +00:00
Daniel Shahaf
d9dd1b63e5 unposted (follow-up to 45131): Extra testing by Mikael 2019-12-26 04:24:31 +00:00
Daniel Shahaf
525faae549 45137: zformat: Allow the specifying minimum width and a dot with an empty maximum width.
Before this commit, format specs such as '%5.s' would be printed
literally.  Now, they are treated as equivalent to '%5s'.

The '.' character is not allowed to be used in specs, so there is no
incompatibility.
2019-12-26 04:21:47 +00:00
Daniel Shahaf
8e0253af02 45138: Add zformat unit tests. 2019-12-26 04:20:24 +00:00
Daniel Shahaf
ca6f4466e6 45131: Make a function that redefines itself preserve its tracedness.
This makes it easy to apply local tracing ('functions -T') to autoloadable
functions that redefines themselves when first loaded.
2019-12-26 04:20:10 +00:00
Daniel Shahaf
5c5ac5efdb unposted: Fix broken build: 45109 (!) broke Test/Y01completion.ztst. 2019-12-22 04:14:58 +00:00
Daniel Shahaf
a0c0aa41d2 45111: zshmisc(1): Clarify the documentation of 'return' and 'exit' in conjunction with try/always
Having reviewed 20076, 20084, 21734, and 21735, my understanding is that
the original intention was:

- A 'return' in a function does run always-list
- An 'exit' outside a function does not run always-list
- A 'return' outside a function is treated as an 'exit'

All of which are the case today.  The remaining case, of 'exit' used
inside a function, was not specified by the referenced -workers@ posts;
does, as implemented, run the always-list; and furthermore, based in
21734 it's fair to assume that the original documentation was assuming
that 'exit' would be used outside of any function, just like it assumed
'return' would be used inside a function.

Therefore, have the documentation specify only the behaviour of 'exit'
outside any function, and leave the behaviour of 'exit' inside
a function unspecified.  Anyone who relied on the documentation of 'exit'
as documented until this commit would have run into the
documentation/implementation discrepancy described in 45075.
2019-12-22 03:21:09 +00:00
Daniel Shahaf
fa7e3146fa 45107: ztst.vim: Highlight some more special variables 2019-12-22 03:20:58 +00:00
Daniel Shahaf
f906ba9d37 45108: ztst.vim: Conceal the '>' or '?' on pattern expected output / expected errput lines.
This aligns the expectations given by '*>' and '>' lines.
2019-12-22 03:20:57 +00:00
Daniel Shahaf
43761827f9 45109: Add Vim highlighting file for Test/*.ztst files. 2019-12-22 03:20:55 +00:00
Daniel Shahaf
26ec82730d unposted: Group related tests. No functional change. 2019-12-21 11:37:21 +00:00
Peter Stephenson
273d669a56 45001: Fix zero-length matches with ${...%...}
As the shortest match is preferred, zero-length matches beat any other.
2019-12-12 10:23:47 +00:00
Martijn Dekker
c578f0a08b 45004: Fix typos in comments 2019-12-11 02:37:39 +00:00
Daniel Shahaf
2acbae3bad unposted: zstyle: Add a unit test and some comments. 2019-12-01 04:00:17 +00:00
Daniel Shahaf
030440d5b7 unposted: Add smoke test for :P history modifier. 2019-11-19 17:57:13 +00:00
Peter Stephenson
d946f22a4c 44664: Fix problem with temporary assignment.
"foo=bar builtin" inside a function lost any variable from
enclosing scope.
2019-08-14 15:16:59 +01:00
Peter Stephenson
4fae525726 Copy functions using functions -c old new.
Documentation and test.
2019-08-03 19:53:51 +01:00
Peter Stephenson
ede3e4e61e 44523: Add ZTST_handler capability.
Defaults to runtests.zsh but can be something else for alternative
test management.
2019-07-16 10:57:35 +01:00
Martijn Dekker
700ec49581 44469: correct error on missing option argument 2019-07-01 09:42:22 +01:00
Peter Stephenson
4384fdc7f0 44446: Fix here document with file descriptor declarator.
Add unit test.
2019-06-24 20:19:19 +01:00
Peter Stephenson
b8dc5a7f6d 44435: Handling digita arguments for :h and :t.
Pick number of leading or trailing path components to substitute.
Active in history, brace parameters, glob qualifiers.

Add tests for all three environments.
2019-06-20 11:13:05 +01:00
Oliver Kiddle
a531a1ec2d 44345: fix wordcode traversal where ! without a following command could result in a crash 2019-05-23 01:05:01 +02:00
Peter Stephenson
30e356eb1a 44296: "typeset Q= {X}" crashed the shell. 2019-05-14 12:10:10 +01:00
dana
cebec8926a unposted: Fix bad encoding in previous Y01 test patch 2019-05-08 18:23:33 -05:00
Oliver Kiddle
ffacb17886 unposted: Add compset tests related to workers/44275
(Provided off-list by Oliver)
2019-05-08 16:38:12 -05:00
Oliver Kiddle
cd6fd2b0a3 44274: allow finer control of completion match soring with compadd's -o option 2019-05-07 23:24:49 +02:00
dana
6f202377c7 44267: sort: Restore option to ignore backslashes
Fix regression introduced by workers/41242
2019-05-03 20:13:48 -05:00
Peter Stephenson
588bb77cb6 44271: Fix breaks propagated from until or return.
If the until or return test caused continuation but there was
a pending return, breaks didn't get cancelled causing enclosing
scope to skip commands.
2019-05-03 20:34:53 +01:00
dana
632023acc2 44100: zparseopts: Add -F option, completion, tests; improve documentation
* Enable zparseopts to perform basic usage validation (aborting on an
  unrecognised option-like parameter)

* Officially document the resolution of ambiguous option specs
2019-03-12 19:03:56 -05:00
Jun-ichi Takimoto
2055ee92e7 unposted: ztst.zsh: fix a typo 2019-03-01 14:57:55 +09:00
dana
ed4c8f3d5e 44030: prompt: Return error for unrecognised colour name 2019-02-03 11:55:40 -06:00
dana
e3cab52ca2 44012: X04zlehighlight: Fix spurious test failures on OpenBSD 2019-01-23 20:35:38 -06:00
Mikael Magnusson
d683d278c7 44011: Only use fg_start_code for non-truecolor
The sequence for truecolor uses a different prefix from palette colors
2019-01-23 11:51:42 +01:00
dana
92b204cb12 43962: Fix X04 test module_path 2018-12-31 10:03:08 -06:00
Peter Stephenson
de31fe1f93 users/23809: ZLE_HIGHLIGHT extensions.
Allow non-termcap use of colours > 7.
Add tests.
2018-12-30 18:18:34 +00:00
Martijn Dekker
2d056ebc31 43945 (tweaked to remove test failure, noted in test):
Fix exit statuses from wait for POSIX_BUILTINS mode.
Also add tests.
2018-12-30 18:11:43 +00:00
Martijn Dekker
4215fcb107 43944: apply NO_UNSET consistently to arithmeitc 2018-12-30 18:03:02 +00:00
Peter Stephenson
d0f92b448e unposted: test for 43938 2018-12-30 17:59:26 +00:00
dana
162c198aab 43953: Fix rounding/truncation error in %. time-format specifier
Also fixes an issue where %. couldn't be used more than once in a format
string without strange results

Tweaked very slightly per workers/43954
2018-12-29 05:24:25 -06:00
dana
f64cd71d44 43935: Reject too-large nanosecond values given to strftime
... and, in so doing, fix an error in the tests on 32-bit machines.

The value for the new too-large test is changed slightly from the patch posted
to the ML to make it test for the right thing on 32-bit machines as well.
2018-12-24 02:42:18 -06:00
Peter Stephenson
50f8fa972c 43837 plus test from Daniel: Empty string in nested subst.
Skip Nularg or there is a bogus character at the start.
2018-11-21 10:10:03 +00:00
dana
5ad76492af 43800: Add nanosecond support to strftime built-in 2018-11-13 13:01:01 -06:00
Daniel Shahaf
73b1328049 43726: Add tests for semicolon in the middle of a sublist not terminating it. 2018-10-24 15:31:42 +00:00
Peter Stephenson
f19266cf99 unposted: another couple of tests for previous commit.
This tests different code paths as the -c command option exits
in a different fashion from code executed from a script.
2018-10-10 12:11:27 +01:00
Peter Stephenson
0d3a786b7c 43669: ensure explicit exit status is used over implicit 2018-10-10 11:17:58 +01:00
Peter Stephenson
bbccbe0c85 43660: extend 43653 when final exit is implicit.
Combine logic for case after committed to exit (shell_exiting) with
case where exit occurred in a function we nee to unwind (exit_pending).

Add sarky note for future generations to be confused at.
2018-10-09 14:38:26 +01:00
Peter Stephenson
afee3c9a19 unposted: addition to previous trap test suggested by Mikael 2018-10-09 11:15:48 +01:00
Peter Stephenson
d768a7492a 43653: explicit exit from EXIT trap overrides exit status 2018-10-09 10:05:05 +01:00
Peter Stephenson
f99f7dca75 43616: Various parameter setting and display fixes.
Mostly to do with typeset -p and tied variables and their interaction.

Some general tied variable fixes.
2018-10-08 10:10:42 +01:00
Daniel Shahaf
64a26b2091 unposted: Add a test for 43546. 2018-09-25 16:38:38 +00:00
Daniel Shahaf
dc2bfeee26 43493: Have V07pcre fail if PCRE was enabled by configure (config.modules) but failed to load for any reason. 2018-09-24 14:15:18 +00:00
Peter Stephenson
1056827194 43466: Make path(5) test more generic.
Only test non-zero status as OS error codes and messages vary.
2018-09-14 09:22:08 +01:00
Peter Stephenson
d6859ce68e 43426: disable job control tests involving suspension.
These are provoking races on OpenSUSE.
2018-09-10 13:48:41 +01:00
Peter Stephenson
9bc7e5b404 43375 with fix from 43390: fix #! tests.
Don't assume path to sh and echo, instead work it out.
2018-09-05 17:58:41 +01:00
Anthony Sottile
1c4c7b6a4d
CVE-2018-0502, CVE-2018-13259: Fix two security issues in shebang line parsing.
See NEWS for more information.

Patch by Anthony Sottile and Buck Evan.
2018-09-03 15:07:47 +00:00
dana
b21a641d4c 43275: Add log2 to match func 2018-08-13 09:36:55 +01:00
Peter Stephenson
f58b35bf88 43264: fix ${+assoc[nonexistent]} with KSH_ARRAYS 2018-08-09 09:48:35 +01:00
Peter Stephenson
225b35c907 43261: Fix unary minus with base.
Apply unary minus to a complete lexical constant rather than the
first component that comes along.
2018-08-08 17:11:54 +01:00
Peter Stephenson
17178db1a4 users/23531: Error exit/return fixes.
Fix regression with trap on left hand side of pipe.

Fix forced return from shell structure within nested function.

Fix tests exiting too early.

Add new test case.
2018-07-09 11:07:53 +01:00
dana
394f3a47e4 43075: Support nanosecond-precision time formatting
* Teach ztrftime() %9. and %N for nanoseconds
* Update prompt expansion to pass sub-second times for time formatting
* Update zsh/stat to pass sub-second times for atime/mtime/ctime

Patch heavily based on Oliver's earlier work @ workers/24059
2018-06-20 17:29:56 -05:00
Peter Stephenson
b05a56a415 unposted: V01zmodload.ztst needs update for parameter module fix 2018-06-18 15:39:19 +01:00
dana
b066cc3ea9 42297: (e) subscript flag needs extra work with scalars 2018-05-14 16:54:19 +01:00
Oliver Kiddle
a93abe1170 42488: test cases for 42369 and address some issues in the code 2018-05-13 10:13:42 +02:00
dana
805192311f 42101 (tweaked): assigning shell status to array was broken 2018-05-11 09:29:14 +01:00
Ricardo Giorni
f7519811e1 47201: fix 42355 for multiple backslashes 2018-04-29 12:05:39 -07:00
Peter Stephenson
2d3b3510a8 c.f. 42726: Back off fg and bg tests.
This is too hard to make robust.  Problems include
- Reading input in different places causes lines to appear and disappear
- There is no easy way to sequence the asynchronous operations
  following bg.
- Response to job control of user commands on some OSes (MacOS,
  for example) is unpredicatble.
2018-04-26 09:42:25 +01:00
Peter Stephenson
bdd595321f 42722: Replace ed with dc in fg/bg tests.
This should be even simpler.

Also more fix ups for failed pattern diffs.
2018-04-25 18:16:02 +01:00
Peter Stephenson
c6dbd862d0 42714: Add fg and bg tests.
Use ed to get minimal user interaction without needing
advanced terminal handling.

Improve test output of failures of pattern differences.
2018-04-25 10:16:51 +01:00
Peter Stephenson
95d861d028 42708: fix for process substitution.
Don't close associated file descriptors in the closem()
tidy up function as they should remain visible to external
processes.  Override if about to exit.

Unit test for the failing case: note this relies on the
existence of /proc/self/fd or equivalent.
2018-04-24 11:48:11 +01:00
Oliver Kiddle
65b265f3c0 42624 (plus test): avoid freeing memory that's still needed
This was occurring in a multiple function definition where a
function name is duplicated.
2018-04-12 23:15:29 +02:00
Oliver Kiddle
25da576c29 42575: fix to not complete options in the argument to another option 2018-04-05 11:14:58 +02:00
Peter Stephenson
3517e4a9a5 42581(?): Fix ZLE inline history expansion.
Seen with magic-space.

If there's a parse error in command subtitution we need to complete
reading history to ensure the command line buffer is finished.
2018-04-04 18:33:00 +01:00
Martijn Dekker
fa0105f78c 42538: Temporarily set umask for here document.
Done while signals are queued.
2018-03-27 09:32:55 +01:00
Peter Stephenson
47aa60950c 42355: Fix use of backslashes on here doc input.
Handling of white space in particular was confusing and inconsistent
with other shells.
2018-02-12 10:06:45 +00:00
dana
1af28cbfd7 42164: fix digits in format escapes in completion listings 2018-01-04 17:16:18 +00:00
Peter Stephenson
5f6a52c06c 42156: new CHECK_RUNNING_JOBS option demanded by bash groupies
Also new job options.

Also suppress debug error if rows or columns are reported as zero as
this is normal without a physical terminal.
2017-12-22 20:21:23 +00:00
dana
932ed86483 dana: 42145: Fix additional completion cases with option arguments. 2017-12-20 09:07:28 +00:00
Daniel Shahaf
4b55c0f40c 42146: type -w += global aliases
Follow-up to 36403, which did the same for suffix aliases.
2017-12-20 05:43:42 +00:00
Jun-ichi Takimoto
5f33a93afb 42116: multibyte support for ZLE vi-mode word motion 2017-12-18 12:48:25 +09:00
Peter Stephenson
aab0f6d763 42123 (tweaked): take account of Dash in function names.
Needed when comparing word code function name with autoload request.

Add test.
2017-12-15 09:00:37 +00:00
dana
cb04ae40af add millisecond and microsecond options to TIMEFMT variable 2017-12-14 15:36:46 +00:00
Peter Stephenson
97c74dcb0e 42110: Fix redirections between variable assignments at start of line 2017-12-12 09:13:41 +00:00
dana
2bc02b4f98 42065: new getopts tests 2017-12-01 09:51:17 +00:00
Daniel Shahaf
77a39b57bf 42031 + 42048: Make [[ -o invalidoption ]] a normal(ish) false value, rather than a syntax error. 2017-11-24 22:10:27 +00:00
Oliver Kiddle
1bfcff129d 41983: fix exclusion of long options with (-) on a normal argument 2017-11-04 00:57:48 +01:00
Barton E. Schaefer
dcd4f02845 41902: ${(z)...} continues parsing on unmatched quote when CSH_JUNKIE_QUOTES is set
Tests for 41902 and 41873
2017-10-17 20:29:47 -07:00
Peter Stephenson
b3fa5c528c 41877: Separate out SH_FILE_EXPANSION loop from parameter substitution.
Parameter substitution can add nodes that need to be rescanned by
it, but not by file expansion, so the two don't play well together.
2017-10-13 18:17:09 +01:00
Barton E. Schaefer
b84d69cf52 41828, 41830: skip SHFILEEXPANSION for new nodes added by stringsubst() in prefork() 2017-10-08 18:08:09 -07:00
Oliver Kiddle
12902206b7 41824: fix to not complete rest args from an _arguments set alongside the argument to and option in a separate set 2017-10-07 22:35:59 +02:00
Peter Stephenson
174e560a23 41787 (plus minor tweaks): use $FUNCSTACK for function nesting depth.
Initialised from existing configuration value.
2017-10-02 09:44:26 +01:00
Peter Stephenson
728f2adfc8 Add typeset -p1, like typeset -p with newlines 2017-10-01 17:53:56 +01:00
Peter Stephenson
7cb55668c2 41773: Array index assignment tests for KSH_ARRAYS 2017-09-28 10:59:38 +01:00
Oliver Kiddle
80a02c10aa 41772: fix bug in handling of long options with _arguments' -A option 2017-09-28 09:31:35 +02:00
Peter Stephenson
6230e82d44 41764 (test tweaked): allow [key]+=value when modifying arrays 2017-09-27 09:41:50 +01:00
Peter Stephenson
85b0dd7133 Updates for ksh array element syntax.
Move detection of key/value pairs down into prefork().

Detect normal array assignment and [key]=val array assignemnt
separately.  Mark key / value pairs with Marker and pass up flag.  Deal
with marked triads specially later on.
2017-09-24 17:33:07 +01:00
Peter Stephenson
ab7be4238c More [key]=value tweaks
Some rephrasings.

Update typeset -p for associative arrays to use new syntax.
2017-09-14 21:43:37 +01:00
Peter Stephenson
54b3958440 First go at var=([key]=value) syntax.
Works for both normal and typeset case, also var+=...

Still to do: allow to be mixed with straight array assignment,
improve typeset -p, implement [key]+=value.
2017-09-13 20:54:00 +01:00
Peter Stephenson
2ef3dff65a 41668: New --emulate option on invocation.
This sets the shell emulation mode similarly to ARGV0=... which
doesn't work from other shells.

Note that this gives more comprehensive emulation than running
emulate within the shell.
2017-09-11 10:12:17 +01:00
Peter Stephenson
c9df6bc8d4 41662: exec -a arguments weren't sanitised 2017-09-10 18:02:52 +01:00
Peter Stephenson
e44600d9aa 41661: Need to remove tokens before using bufferwords() for (z) 2017-09-10 18:01:39 +01:00
Peter Stephenson
ea5b38935a 41641: Some math operations shouldn't be lvalues.
This includes pre- and post- increment and decrement.  Simply
mark all values after operations as rvalues.
2017-09-05 13:15:30 +01:00
Peter Stephenson
ebcea98eca Fix problem with ERR_RETURN.
It wasn't suppressed properly in the code following an if
in some circumstances, in particular in initialsation scripts
and also in a nested function where the caller had suppressed
it.
2017-08-31 16:54:19 +01:00
Peter Stephenson
7d1877da4e 41608 (plus tests): restore ERR_EXIT before function.
There was an exception to the usual ERR_EXIT pattern that causes
problems when executing a function in an else branch.  It seems
the exception is no longer needed as the regression tests pass
without it.
2017-08-29 19:52:18 +01:00
Peter Stephenson
97d4bdbc7e 41590 modified as 41595: make ERR_RETURN more logical.
It now operates separately at each function depth.

To keep ERR_EXIT global, make the noerrexit variable usd bit flags.

Extend tests.
2017-08-24 19:46:20 +01:00
Peter Stephenson
74aff4106a 41542: Fix pcre logic for extracting matched parentheses.
When we went off the end of the array but measured the length
implicitly, we got lucky before.  After 41308 we were looking up lengths
in stale memory.

Rename some variables, clean up the logic, be easier to understand.

Add tests.
2017-08-14 11:17:48 +01:00
Phil Pennock
b5f40f4156 41527 (tweaked for heap memory): fix [[ -<cond> ]] from modules 2017-08-11 15:02:06 +01:00
Peter Stephenson
cfd34c75ac 41504: make empty strings work in case patterns with no leading parenthesis 2017-08-09 19:57:47 +01:00
Peter Stephenson
a9b579a9d3 Revert "41499 (with one further tweak): POSIX_STRINGS behaviour."
This reverts commit 2eacbef919.

Conflicts:
	ChangeLog
2017-08-08 19:04:49 +01:00
Peter Stephenson
2eacbef919 41499 (with one further tweak): POSIX_STRINGS behaviour.
Ignore a terminating delimiter when splitting as separators
despite being called separators are terminators.
2017-08-07 18:47:43 +01:00
Peter Stephenson
039a34cca5 41485: test for previous fix 2017-08-03 21:50:18 +01:00
Peter Stephenson
d4b94b5e83 41464, 41466: With POSIX_BUILTINS, exec only executes sexternal commands.
Document the default behaviour and add a test.
2017-07-27 09:22:04 +01:00
Peter Stephenson
a3b3f00575 41420: "{.." wasn't check for brace expansion properly 2017-07-13 17:20:24 +01:00
Peter Stephenson
e8edd42f7f 22760: fix partial string length reports with NO_MULTIBYTE 2017-07-02 20:29:00 +01:00
Phil Pennock
825f84c77e 41308 (tweaked): behaviour of PCRE with NUL bytes 2017-06-22 09:24:33 +01:00
Peter Stephenson
eb783754bd 41284: Fix NULL dereference in cd.
This happened in sh compatiblity mode if HOME was not set
and cd was used with no argument.
2017-06-13 15:41:00 +01:00
Peter Stephenson
1caaa933b4 unposted: Adding comments to test changed line number in output 2017-05-09 21:02:34 +01:00
Peter Stephenson
c7a9cf465d 40181: Fix buffer overrun in xsymlinks.
There was no check for copying to the internal xbuf2 for a
preliminary test.
2017-05-09 17:49:18 +01:00
Peter Stephenson
263a0c2476 41078: Empty psvar could cause bad dereference in prompt expansion 2017-05-09 09:46:23 +01:00
Peter Stephenson
af1c82d646 40173: Off-by-one error checking for {varid}.
This caused a single unprintable character in braces before a
redirection to be treated as an indentifier.
2017-05-08 18:00:55 +01:00
Peter Stephenson
641a764b82 users/22688: Allow mixing redirs and arguments after anon functions.
These are parsed differently from the case of normal functions which
can't take normal arguments at that point.
2017-05-08 17:19:22 +01:00
Peter Stephenson
f25d01a97c Fix combination of HERE document and |&.
A missing flag setting up the HERE document mean that the size
of the wordcode needed to append the 2>&1 was counted incorrectly,
so the resulting wordcode was garbled.

Add test.
2017-05-08 10:54:08 +01:00
Peter Stephenson
ed4e37e45c 41020: Fix "command -p"; "-p" was incorrectly left in command arguments
Also add tests for known precommand modifier issues.
2017-04-28 10:22:43 +01:00
Peter Stephenson
d7110d8f01 41012: Fix premature exit from nested function in EXIT trap.
Also add check so we don't delay an exit if we were already in
an EXIT trap for the main shell, as we should in that case leave
immediately.
2017-04-27 18:56:18 +01:00
Peter Stephenson
48b0daf3d4 41016: Test that quoted precommand modifiers now work 2017-04-27 09:58:45 +01:00
Peter Stephenson
408b92b168 41008: Handle expansions for precommand modifiers 2017-04-26 09:44:38 +01:00
Peter Stephenson
68466f327e 40995: Don't disable alias expansion when finding command substitution limits
This is needed in some unusual cases in order to identify the exit
condition without encountering a parse error.
2017-04-23 17:06:26 +01:00