From ca6f4466e661f185d083e09c55fb93d16e0736cc Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 22 Dec 2019 04:52:38 +0000 Subject: [PATCH 01/14] 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. --- ChangeLog | 5 +++++ Src/exec.c | 6 ++++++ Test/E02xtrace.ztst | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3b82468c7..a9bf59c5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-12-26 Daniel Shahaf + + * 45131: Src/exec.c, Test/E02xtrace.ztst: Make a function that + redefines itself preserve its tracedness. + 2019-12-23 Daniel Shahaf * unposted: Completion/Unix/Command/_stdbuf: Fix mismatch diff --git a/Src/exec.c b/Src/exec.c index fac095d64..356e2974b 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -5320,6 +5320,12 @@ execfuncdef(Estate state, Eprog redir_prog) */ removetrapnode(signum); } + /* Is this function traced and redefining itself? */ + if (funcstack && funcstack->tp == FS_FUNC && + !strcmp(s, funcstack->name)) { + Shfunc old = ((Shfunc)shfunctab->getnode(shfunctab, s)); + shf->node.flags |= old->node.flags & (PM_TAGGED|PM_TAGGED_LOCAL); + } shfunctab->addnode(shfunctab, ztrdup(s), shf); } } diff --git a/Test/E02xtrace.ztst b/Test/E02xtrace.ztst index da6191cd0..8d2c300cf 100644 --- a/Test/E02xtrace.ztst +++ b/Test/E02xtrace.ztst @@ -146,3 +146,12 @@ ?+(anon):0> '(anon)' ?+(anon):0> true ?+fn:0> gn + + f() { + f() { echo inner } + } + functions -T f + f + which f | grep '# traced' +0:a function that redefines itself preserves tracing +> # traced From 8e0253af022abe9f9225352aae1088d6621a81ab Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 24 Dec 2019 18:25:08 +0000 Subject: [PATCH 02/14] 45138: Add zformat unit tests. --- ChangeLog | 3 ++ Src/Modules/zutil.c | 6 ++-- Test/V13zformat.ztst | 65 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 3 deletions(-) create mode 100644 Test/V13zformat.ztst diff --git a/ChangeLog b/ChangeLog index a9bf59c5b..fe3b6951c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2019-12-26 Daniel Shahaf + * 45138: Src/Modules/zutil.c, Test/V13zformat.ztst: Add zformat + unit tests. + * 45131: Src/exec.c, Test/E02xtrace.ztst: Make a function that redefines itself preserve its tracedness. diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index 24659cb16..de5fe8034 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -913,13 +913,13 @@ bin_zformat(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) switch (opt) { case 'f': { - char **ap, *specs[256], *out; + char **ap, *specs[256] = {0}, *out; int olen, oused = 0; - memset(specs, 0, 256 * sizeof(char *)); - specs['%'] = "%"; specs[')'] = ")"; + + /* Parse the specs in argv. */ for (ap = args + 2; *ap; ap++) { if (!ap[0][0] || ap[0][0] == '-' || ap[0][0] == '.' || idigit(ap[0][0]) || ap[0][1] != ':') { diff --git a/Test/V13zformat.ztst b/Test/V13zformat.ztst new file mode 100644 index 000000000..d8de2bb04 --- /dev/null +++ b/Test/V13zformat.ztst @@ -0,0 +1,65 @@ +# Test the use of zformat, if the zsh/zutil module is available. + +%prep + + if ! zmodload zsh/zutil 2>/dev/null; then + ZTST_unimplemented="can't load the zsh/zutil module for testing" + fi + + # Helper function. Expects a single format using %s and a value for it. + zformat_and_print_s() { + zformat -f REPLY "$1" "s:$2" + print -r - ${(qq)REPLY} + } + +%test + + zformat_and_print_s '%s' foo + zformat_and_print_s '%5s' min + zformat_and_print_s '%-5s' neg + zformat_and_print_s '%.5s' max + zformat_and_print_s '%.5s' truncated +0:basic zformat test +>'foo' +>'min ' +>' neg' +>'max' +>'trunc' + + # There may be a set of digits either before or after the opening parenthesis. + zformat_and_print_s 'The answer is "%3(s.yes.no)".' 3 + zformat_and_print_s 'The answer is "%(3s.yes.no)".' 3 + # The test number defaults to zero. + zformat_and_print_s '%(s.equal.unequal)' -1 + zformat_and_print_s '%(s.equal.unequal)' 0 + zformat_and_print_s '%(s.equal.unequal)' 1 + # Negative numbers are allowed + # The delimiter is arbitrary + zformat_and_print_s '%-4(s.minus four.)' -4 + zformat_and_print_s '%(-4s//minus four)' -4 + # The argument is evaluated as a math expression + zformat_and_print_s '%18(s.math.)' '6*3' +0:basic conditionals test +>'The answer is "yes".' +>'The answer is "yes".' +>'unequal' +>'equal' +>'unequal' +>'minus four' +>'' +>'math' + + () { + zformat -f 1 '%(8n.%(5j.yes.no).no)' 'n:8' 'j:5' + echo $1 + } +0:nested conditionals test +>yes + + zformat -a argv . foo:lorem ipsum:bar bazbaz '\\esc\:ape' + print -rl -- "$@" +0:basic -a test +>foo .lorem +>ipsum.bar +>bazbaz +>\esc:ape From 525faae5498adb4b4f1c0f4657b9ef71fc31c4d6 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 24 Dec 2019 18:25:09 +0000 Subject: [PATCH 03/14] 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. --- ChangeLog | 4 ++++ Src/Modules/zutil.c | 3 +-- Test/V13zformat.ztst | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe3b6951c..321216c7a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2019-12-26 Daniel Shahaf + * 45137: Src/Modules/zutil.c, Test/V13zformat.ztst: zformat: + Allow the specifying minimum width and a dot with an empty + maximum width. + * 45138: Src/Modules/zutil.c, Test/V13zformat.ztst: Add zformat unit tests. diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index de5fe8034..7d9bf05d6 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -797,8 +797,7 @@ static char *zformat_substring(char* instr, char **specs, char **outp, if ((*s == '.' || testit) && idigit(s[1])) { for (max = 0, s++; idigit(*s); s++) max = (max * 10) + (int) STOUC(*s) - '0'; - } - else if (testit) + } else if (*s == '.' || testit) s++; if (testit && STOUC(*s)) { diff --git a/Test/V13zformat.ztst b/Test/V13zformat.ztst index d8de2bb04..982866e13 100644 --- a/Test/V13zformat.ztst +++ b/Test/V13zformat.ztst @@ -17,12 +17,14 @@ zformat_and_print_s '%s' foo zformat_and_print_s '%5s' min zformat_and_print_s '%-5s' neg + zformat_and_print_s '%5.s' empty zformat_and_print_s '%.5s' max zformat_and_print_s '%.5s' truncated 0:basic zformat test >'foo' >'min ' >' neg' +>'empty' >'max' >'trunc' From d9dd1b63e510057d16123a6deb4e4782884883d7 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 22 Dec 2019 06:53:58 +0000 Subject: [PATCH 04/14] unposted (follow-up to 45131): Extra testing by Mikael --- ChangeLog | 3 +++ Test/E02xtrace.ztst | 37 +++++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 321216c7a..c6504d882 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2019-12-26 Daniel Shahaf + * unposted (follow-up to 45131): Test/E02xtrace.ztst: Extra + testing by Mikael + * 45137: Src/Modules/zutil.c, Test/V13zformat.ztst: zformat: Allow the specifying minimum width and a dot with an empty maximum width. diff --git a/Test/E02xtrace.ztst b/Test/E02xtrace.ztst index 8d2c300cf..a5a7bc55c 100644 --- a/Test/E02xtrace.ztst +++ b/Test/E02xtrace.ztst @@ -147,11 +147,36 @@ ?+(anon):0> true ?+fn:0> gn - f() { - f() { echo inner } - } - functions -T f - f - which f | grep '# traced' + test_cases=( + f # baseline + foo-bar # Dash + ヌ # Meta (the UTF-8 representation of this character has an 0x83 byte) + \$\'ba\\0z\' # Nul, escaped as though by ${(qqqq)} + ) + for 1 in "$test_cases[@]"; do + eval " + ${1}() { + ${1}() { echo inner } + } + functions -T ${1} + ${1} + which ${1} + " + done 0:a function that redefines itself preserves tracing +>f () { > # traced +> echo inner +>} +>foo-bar () { +> # traced +> echo inner +>} +>$'\M-c\M-\C-C\M-\C-L' () { +> # traced +> echo inner +>} +>$'ba\C-@z' () { +> # traced +> echo inner +>} From 2dac9c5d204a98a1cc512a4397901b8b9727fc80 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Fri, 3 Jan 2020 20:08:42 +0000 Subject: [PATCH 05/14] 45213: Make --enable-gdbm default to false, rather than default to true with an unavoidable warning. --- ChangeLog | 5 +++++ README | 4 ++++ configure.ac | 14 +++----------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index c6504d882..399623a10 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-06 Daniel Shahaf + + * 45213: README, configure.ac: Make --enable-gdbm default to + false, rather than default to true with an unavoidable warning. + 2019-12-26 Daniel Shahaf * unposted (follow-up to 45131): Test/E02xtrace.ztst: Extra diff --git a/README b/README index a3701abe5..bcec3def1 100644 --- a/README +++ b/README @@ -33,6 +33,10 @@ details, see the documentation. Incompatibilities since 5.7.1 ----------------------------- +Build-time change: The default value of the --enable-gdbm configure +argument has changed from "yes" to "no". Thus, the zsh/db/gdbm module will +not be built unless --enable-gdbm is passed explicitly. + The history expansion !:1:t2 used to be interpreted such that the 2 was a separate character added after the history expansion. Now it is an argument to the :t modifier. diff --git a/configure.ac b/configure.ac index 8fd4d452f..256584538 100644 --- a/configure.ac +++ b/configure.ac @@ -444,9 +444,10 @@ dnl Do you want to look for capability support? AC_ARG_ENABLE(cap, AS_HELP_STRING([--enable-cap],[enable the search for POSIX capabilities (may require additional headers to be added by hand)])) +# Default off for licensing reasons AC_ARG_ENABLE(gdbm, -AS_HELP_STRING([--disable-gdbm],[turn off search for gdbm library]), -[gdbm="$enableval"], [gdbm=yes]) +AS_HELP_STRING([--enable-gdbm],[enable the search for the GDBM library (see the zsh/db/gdbm module)]), +[gdbm="$enableval"], [gdbm=no]) dnl ------------------ dnl CHECK THE COMPILER @@ -3298,13 +3299,4 @@ fi echo "See config.modules for installed modules and functions. " -case x$LIBS in - *-lgdbm*) - echo "WARNING: zsh will be linked against libgdbm. -This means the binary is covered by the GNU General Public License. -This does not affect the source code. -Run configure with --disable-gdbm if required." - ;; -esac - exit 0 From 819204346025aaaed205c9191ec7a1729cf146e3 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 5 Jan 2020 19:13:22 +0000 Subject: [PATCH 06/14] 45246: Make --disable-multibyte warn, since the test suite fails in that configuration. --- ChangeLog | 5 +++++ configure.ac | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 399623a10..c97db5969 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-06 Daniel Shahaf + + * 45246: configure.ac: Make --disable-multibyte warn, since + the test suite fails in that configuration. + 2020-01-06 Daniel Shahaf * 45213: README, configure.ac: Make --enable-gdbm default to diff --git a/configure.ac b/configure.ac index 256584538..4556d3806 100644 --- a/configure.ac +++ b/configure.ac @@ -2553,6 +2553,7 @@ wmemcpy wmemmove wmemset; do AC_MSG_NOTICE([all functions found, multibyte support enabled]) zsh_cv_c_unicode_support=yes else + # Warns at the end of configure AC_MSG_NOTICE([missing functions, multibyte support disabled]) zsh_cv_c_unicode_support=no fi @@ -3299,4 +3300,18 @@ fi echo "See config.modules for installed modules and functions. " +if test x$zsh_cv_c_unicode_support != xyes; then + if test "x$zfuncs_absent" = x; then + # The user opted out. + AC_MSG_WARN([You have chosen to build without multibyte support.]) + AC_MSG_WARN([This configuration may not be suitable for production use. It is known to cause errors in 'make test'. We strongly recommend to re-run configure with --enable-multibyte.]) + else + # Some requisite functions are missing. + AC_MSG_WARN([Multibyte support cannot be enabled: some standard library functions are missing: $zfuncs_absent]) + AC_MSG_WARN([This configuration may not be suitable for production use. It is known to cause errors in 'make test'. If your system provides those functions, we recommend to re-run configure appropriately.]) + # If your system doesn't have those functions, consider patching the + # test suite and sending the patch to zsh-workers@ for inclusion. + fi +fi + exit 0 From 22c0fe02a53bedb03f6aef5d0e476bbadc655995 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 12 Jan 2020 22:29:27 +0000 Subject: [PATCH 07/14] 45288: _git: Complete bisect/new as well as bisect/bad. Also, complete the bisect/old-$commithash ref names. --- ChangeLog | 5 +++++ Completion/Unix/Command/_git | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c97db5969..18d8e9ae6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-15 Daniel Shahaf + + * 45288: Completion/Unix/Command/_git: Complete bisect/new as + well as bisect/bad. + 2020-01-06 Daniel Shahaf * 45246: configure.ac: Make --disable-multibyte warn, since diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index be0c810cc..fa3d99f2f 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -6702,14 +6702,12 @@ __git_heads_local () { local f gitdir declare -a heads - heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)"' refs/heads 2>/dev/null)"}) + heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)"' refs/heads refs/bisect refs/stash 2>/dev/null)"}) gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) if __git_command_successful $pipestatus; then for f in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do [[ -f $gitdir/$f ]] && heads+=$f done - [[ -f $gitdir/refs/stash ]] && heads+=stash - [[ -f $gitdir/refs/bisect/bad ]] && heads+=bisect/bad fi __git_describe_commit heads heads-local "local head" "$@" From edc04bd94656a152e17f06188bcef172d62a3ad4 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 13 Jan 2020 00:27:24 +0000 Subject: [PATCH 08/14] 45291: A glob with a trailing slash will now match unreadable/unexecutable directories. --- ChangeLog | 5 +++++ Src/glob.c | 51 +++++++++++++++++++++++++++++++++++++---------- Test/D02glob.ztst | 2 +- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 44b45ce07..d6ad77e3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-15 dana + + * Daniel: 45291: Src/glob.c, Test/D02glob.ztst: A glob with a + trailing slash will now match unreadable/unexecutable directories. + 2020-01-15 Daniel Shahaf * 45288: Completion/Unix/Command/_git: Complete bisect/new as diff --git a/Src/glob.c b/Src/glob.c index f67a376b9..bee890caf 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -279,11 +279,11 @@ addpath(char *s, int l) * foo/ can be used to reference a non-directory foo. Returns nonzero if * * the file does not exists. */ -/**/ static int statfullpath(const char *s, struct stat *st, int l) { char buf[PATH_MAX+1]; + int check_for_being_a_directory = 0; DPUTS(strlen(s) + !*s + pathpos - pathbufcwd >= PATH_MAX, "BUG: statfullpath(): pathname too long"); @@ -294,16 +294,44 @@ statfullpath(const char *s, struct stat *st, int l) * Don't add the '.' if the path so far is empty, since * then we get bogus empty strings inserted as files. */ - buf[pathpos - pathbufcwd] = '.'; - buf[pathpos - pathbufcwd + 1] = '\0'; - l = 0; + if (st) { + buf[pathpos - pathbufcwd] = '.'; + buf[pathpos - pathbufcwd + 1] = '\0'; + l = 0; + } + else { + check_for_being_a_directory = 1; + } } unmetafy(buf, NULL); - if (!st) { - char lbuf[1]; - return access(buf, F_OK) && (!l || readlink(buf, lbuf, 1) < 0); + if (st) { + return l ? lstat(buf, st) : stat(buf, st); + } + else if (check_for_being_a_directory) { + struct stat tmp; + if (stat(buf, &tmp)) + return -1; + + return S_ISDIR(tmp.st_mode) ? 0 : -1; + } + else { + char lbuf[1]; + + /* If it exists, signal success. */ + if (access(buf, F_OK) == 0) + return 0; + + /* Would a dangling symlink be good enough? */ + if (l == 0) + return -1; + + /* Is it a dangling symlink? */ + if (readlink(buf, lbuf, 1) >= 0) + return 0; + + /* Guess it doesn't exist, then. */ + return -1; } - return l ? lstat(buf, st) : stat(buf, st); } /* This may be set by qualifier functions to an array of strings to insert @@ -327,11 +355,13 @@ insert(char *s, int checked) if (gf_listtypes || gf_markdirs) { /* Add the type marker to the end of the filename */ mode_t mode; - checked = statted = 1; if (statfullpath(s, &buf, 1)) { unqueue_signals(); return; } + else { + checked = statted = 1; + } mode = buf.st_mode; if (gf_follow) { if (!S_ISLNK(mode) || statfullpath(s, &buf2, 0)) @@ -387,11 +417,10 @@ insert(char *s, int checked) qn = qn->next; } } else if (!checked) { - if (statfullpath(s, &buf, 1)) { + if (statfullpath(s, NULL, 1)) { unqueue_signals(); return; } - statted = 1; news = dyncat(pathbuf, news); } else news = dyncat(pathbuf, news); diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index 3d7df94c9..b8946c5b1 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -734,7 +734,7 @@ mkdir -m 444 glob.tmp/secret-d444 for 1 in 000 111 444 ; do ln -s secret-d$1 glob.tmp/secret-s$1; done print -rC 2 -- glob.tmp/secret-*/ glob.tmp/secret-*(-/) --f:unreadable directories can be globbed (users/24619, users/24626) +0:unreadable directories can be globbed (users/24619, users/24626) >glob.tmp/secret-d000/ glob.tmp/secret-d000 >glob.tmp/secret-d111/ glob.tmp/secret-d111 >glob.tmp/secret-d444/ glob.tmp/secret-d444 From 977e1c75d8fcd7e727d20d8e4ac9b5b79ea9d667 Mon Sep 17 00:00:00 2001 From: dana Date: Wed, 15 Jan 2020 19:31:16 -0600 Subject: [PATCH 09/14] 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 --- ChangeLog | 3 +++ Test/D02glob.ztst | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index d6ad77e3b..c317f04c5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2020-01-15 dana + * 45292: Test/D02glob.ztst: Add regression test for macOS stat(2) + misbehaviour, now worked around by previous fix (see workers/42891) + * Daniel: 45291: Src/glob.c, Test/D02glob.ztst: A glob with a trailing slash will now match unreadable/unexecutable directories. diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index b8946c5b1..7fd22d795 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -742,6 +742,17 @@ >glob.tmp/secret-s111/ glob.tmp/secret-s111 >glob.tmp/secret-s444/ glob.tmp/secret-s444 + # On macOS, stat(2) allows files to be treated as directories if the calling + # process has super-user privileges. e.g., stat() on /my/regular/file/. will + # succeed as root but (correctly) fail otherwise. This can produce strange + # results when globbing, depending on how it's implemented. This test should, + # when run with privileges, confirm that the implementation avoids this + # problem. See workers/42891 and workers/45291 + : > glob.tmp/not-a-directory + print -r - glob.tmp/not-a-dir*(N) , glob.tmp/not-a-dir*/(N) +0:non-directories not globbed as directories +>glob.tmp/not-a-directory , + %clean # Fix unreadable-directory permissions so ztst can clean up properly From 7ca2b06501b463641426d009a54b21b89b8ca9ee Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 15 Jan 2020 18:02:33 +0000 Subject: [PATCH 10/14] 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). --- ChangeLog | 5 +++++ Src/loop.c | 2 +- Test/A01grammar.ztst | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 643352dfe..675342647 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-16 Daniel Shahaf + + * 45304: Src/loop.c, Test/A01grammar.ztst: Do execute the always + block even when the try/always block itself is the last command. + 2020-01-15 dana * 45292: Test/D02glob.ztst: Add regression test for macOS stat(2) diff --git a/Src/loop.c b/Src/loop.c index 538afb8dc..57858a150 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -742,7 +742,7 @@ exectry(Estate state, int do_exec) /* The :try clause */ ++try_tryflag; - execlist(state, 1, do_exec); + execlist(state, 1, 0); --try_tryflag; /* Don't record errflag here, may be reset. However, */ diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index 1e0e9a04e..0dbf468f6 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -930,5 +930,5 @@ F:Note that the behaviour of 'exit' inside try-list inside a function is unspeci >or false $ZTST_testdir/../Src/zsh -fc '{ ( ) } always { echo foo }' --f:exec last command optimization inhibited for try/always +0:exec last command optimization inhibited for try/always >foo From bcd78756c8d55b1bab3a9f6fa79eb58782d3000e Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 16 Jan 2020 16:42:20 +0000 Subject: [PATCH 11/14] 45313: _git: Support completion from outside of a worktree when --git-dir/--work-tree are specified on the command line Revised version of workers/41523. --- ChangeLog | 6 ++++++ Completion/Unix/Command/_git | 11 +++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 675342647..8285bc49c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2020-01-17 Daniel Shahaf + + * 45313: Completion/Unix/Command/_git: Support completion from + outside of a worktree when --git-dir/--work-tree are specified + on the command line + 2020-01-16 Daniel Shahaf * 45304: Src/loop.c, Test/A01grammar.ztst: Do execute the always diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 8e0d57789..92b72b936 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -7075,21 +7075,23 @@ __git_files_relative () { (( $+functions[__git_files] )) || __git_files () { - local compadd_opts opts tag description gitcdup gitprefix files expl + local compadd_opts opts tag description gittoplevel gitprefix files expl zparseopts -D -E -a compadd_opts V+: J+: 1 2 o+: n f x+: X+: M+: P: S: r: R: q F: zparseopts -D -E -a opts -- -cached -deleted -modified -others -ignored -unmerged -killed x+: --exclude+: tag=$1 description=$2; shift 2 - gitcdup=$(_call_program gitcdup git rev-parse --show-cdup 2>/dev/null) + gittoplevel=$(_call_program toplevel git rev-parse --show-toplevel 2>/dev/null) __git_command_successful $pipestatus || return 1 + [[ -n $gittoplevel ]] && gittoplevel+="/" gitprefix=$(_call_program gitprefix git rev-parse --show-prefix 2>/dev/null) __git_command_successful $pipestatus || return 1 # TODO: --directory should probably be added to $opts when --others is given. - local pref=$gitcdup$gitprefix$PREFIX + local pref=${(Q)${~PREFIX}} + [[ $pref[1] == '/' ]] || pref=$gittoplevel$gitprefix$pref # First allow ls-files to pattern-match in case of remote repository files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\*}:-.} 2>/dev/null)"}) @@ -8131,7 +8133,8 @@ _git() { ;; (option-or-argument) curcontext=${curcontext%:*:*}:git-$words[1]: - (( $+opt_args[--git-dir] )) && local -x GIT_DIR=$opt_args[--git-dir] + (( $+opt_args[--git-dir] )) && local -x GIT_DIR=${(Q)${~opt_args[--git-dir]}} + (( $+opt_args[--work-tree] )) && local -x GIT_WORK_TREE=${(Q)${~opt_args[--work-tree]}} if ! _call_function ret _git-$words[1]; then if [[ $words[1] = \!* ]]; then words[1]=${words[1]##\!} From b4996ea5ebdfda1b07bae83be64eaa1ef21baa6d Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 29 Jan 2020 08:30:13 +0000 Subject: [PATCH 12/14] 45342: Add tests for interaction between autoloadable parameters and module loading. --- ChangeLog | 5 +++++ Test/V01zmodload.ztst | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8285bc49c..b14bb3e3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-01-29 Daniel Shahaf + + * 45342: Test/V01zmodload.ztst: Add tests for interaction + between autoloadable parameters and module loading. + 2020-01-17 Daniel Shahaf * 45313: Completion/Unix/Command/_git: Support completion from diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index 1bd8c1900..237b7d2dc 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -348,6 +348,47 @@ ?(eval):6: unknown function: systell ?(eval):9: file descriptor out of range + $ZTST_testdir/../Src/zsh -fc ' + if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi + unset options + zmodload zsh/parameter + echo $+options + ' +-f:can unset a non-readonly autoloadable parameter before loading the module +>0 +# Currently prints '1'. + + $ZTST_testdir/../Src/zsh -fc ' + zmodload zsh/parameter + unset options + echo $+options + ' +0:can unset a non-readonly autoloadable parameter after loading the module +>0 + + $ZTST_testdir/../Src/zsh -fc ' + if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi + unset builtins + ' +-f:can't unset a readonly autoloadable parameter before loading the module +*?zsh:?: read-only variable: builtins +# Currently, the 'unset' succeeds. + + $ZTST_testdir/../Src/zsh -fc ' + zmodload zsh/parameter + unset builtins + ' +1:can't unset a readonly autoloadable parameter after loading the module +?zsh:3: read-only variable: builtins + + $ZTST_testdir/../Src/zsh -fc ' + zmodload zsh/parameter + zmodload -u zsh/parameter + echo $options + ' +0:unloading a module doesn't implicitly unset autoloadable parameters +*>(on|off) * + %clean eval "$deps" From 0d3d07c56f75064310271bf4469c5c9c13145d58 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 7 Mar 2020 21:32:38 +0000 Subject: [PATCH 13/14] unposted: Fix trailing whitespace in test expectations. --- ChangeLog | 5 +++++ Test/V01zmodload.ztst | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b14bb3e3a..a1b3b2d75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-03-07 Daniel Shahaf + + * unposted: Test/V01zmodload.ztst: Fix trailing whitespace in + test expectations. + 2020-01-29 Daniel Shahaf * 45342: Test/V01zmodload.ztst: Add tests for interaction diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index 237b7d2dc..339df7436 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -355,7 +355,7 @@ echo $+options ' -f:can unset a non-readonly autoloadable parameter before loading the module ->0 +>0 # Currently prints '1'. $ZTST_testdir/../Src/zsh -fc ' @@ -364,7 +364,7 @@ echo $+options ' 0:can unset a non-readonly autoloadable parameter after loading the module ->0 +>0 $ZTST_testdir/../Src/zsh -fc ' if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi @@ -387,7 +387,7 @@ echo $options ' 0:unloading a module doesn't implicitly unset autoloadable parameters -*>(on|off) * +*>(on|off) * %clean From 4ce0cff5e91608598adf4a72318fc868681e398d Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 7 Mar 2020 21:50:23 +0000 Subject: [PATCH 14/14] unposted: Move a new incompatibility notice. The change in question was (deliberately) not merged to master before the 5.8 release. Therefore, it is a "post 5.8" change, even though it was written when 5.7.1 was the latest release. --- ChangeLog | 2 ++ README | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b26340e43..23d70c410 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2020-03-07 Daniel Shahaf + * unposted: README: Move a new incompatibility notice. + * unposted: Test/V01zmodload.ztst: Fix trailing whitespace in test expectations. diff --git a/README b/README index 589c10da5..b8dfd0e2a 100644 --- a/README +++ b/README @@ -31,13 +31,16 @@ Zsh is a shell with lots of features. For a list of some of these, see the file FEATURES, and for the latest changes see NEWS. For more details, see the documentation. -Incompatibilities since 5.7.1 ------------------------------ +Incompatibilities since 5.8 +--------------------------- Build-time change: The default value of the --enable-gdbm configure argument has changed from "yes" to "no". Thus, the zsh/db/gdbm module will not be built unless --enable-gdbm is passed explicitly. +Incompatibilities since 5.7.1 +----------------------------- + The history expansion !:1:t2 used to be interpreted such that the 2 was a separate character added after the history expansion. Now it is an argument to the :t modifier.