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.
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.)
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.
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.
* 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
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.
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.
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.
- 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
* 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.
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
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.
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.)
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.
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.
Pick number of leading or trailing path components to substitute.
Active in history, brace parameters, glob qualifiers.
Add tests for all three environments.
* Enable zparseopts to perform basic usage validation (aborting on an
unrecognised option-like parameter)
* Officially document the resolution of ambiguous option specs
... 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.
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.
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.
* 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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.