From 71bd576af836517bda6dd574ef81176339144568 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sun, 29 Oct 2023 13:13:49 -0500 Subject: [PATCH 01/10] CI += zsh 5.9 --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 60818a6..76a7484 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: matrix: version: - master + - 5.9 - 5.8.1 - 5.8 - 5.7.1 From bb27265aeeb0a22fb77f1275118a5edba260ec47 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sun, 29 Oct 2023 13:25:08 -0500 Subject: [PATCH 02/10] CI: Update action versions --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76a7484..cd50b8a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -57,7 +57,7 @@ jobs: container: image: ghcr.io/zsh-users/zsh:${{ matrix.version }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: install_packages bsdmainutils make procps - run: make test @@ -68,9 +68,8 @@ jobs: steps: - name: Notify IRC - uses: Gottox/irc-message-action@v1 + uses: Gottox/irc-message-action@v2 with: - server: irc.libera.chat channel: '#zsh-syntax-highlighting' nickname: zsyh-gh-bot message: '${{ github.ref }} failed tests: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' From 9bb3db7fd2715e07804b23a78e0eed797e137610 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Mon, 18 Dec 2023 16:02:40 -0600 Subject: [PATCH 03/10] driver: Use stable zsh release in is-at-least calls --- zsh-syntax-highlighting.zsh | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/zsh-syntax-highlighting.zsh b/zsh-syntax-highlighting.zsh index 9f8fe48..4295c93 100644 --- a/zsh-syntax-highlighting.zsh +++ b/zsh-syntax-highlighting.zsh @@ -155,18 +155,7 @@ _zsh_highlight() # C structs, so that none of the previous case patterns will match. # # In either case, fall back to a version check. - # - # The memo= feature was added to zsh in commit zsh-5.8-172-gdd6e702ee. - # The version number at the time was 5.8.0.2-dev (see Config/version.mk). - # Therefore, on zsh master 5.8.0.3 and newer the memo= feature is available. - # However, there's also the zsh 5.8.1 release, which doesn't have the - # memo= feature. - # - # On zsh master 5.8.0.2 between the aforementioned commit and the - # first Config/version.mk bump after it (zsh-5.8-607-g75c1edde5, the - # bump to 5.8.1.1-dev following the backport to master of the bump - # to 5.8.1), this condition will false negative. - if is-at-least 5.8.1.1 $ZSH_VERSION.0.0; then + if is-at-least 5.9; then integer -gr zsh_highlight__memo_feature=1 else integer -gr zsh_highlight__memo_feature=0 @@ -415,9 +404,7 @@ _zsh_highlight_call_widget() # We check this with a plain version number check, since a functional check, # as done by _zsh_highlight, can only be done from inside a widget # function — a catch-22. -# -# See _zsh_highlight for the magic version number. -if is-at-least 5.8.1.1 $ZSH_VERSION.0.0 && _zsh_highlight__function_callable_p add-zle-hook-widget +if is-at-least 5.9 && _zsh_highlight__function_callable_p add-zle-hook-widget then autoload -U add-zle-hook-widget _zsh_highlight__zle-line-finish() { From db085e4661f6aafd24e5acb5b2e17e4dd5dddf3e Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Mon, 18 Dec 2023 16:05:43 -0600 Subject: [PATCH 04/10] Tag version 0.8.0. --- .version | 2 +- changelog.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.version b/.version index 9fb1210..a3df0a6 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.8.0-alpha2-dev +0.8.0 diff --git a/changelog.md b/changelog.md index 851a918..bc6614d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,6 @@ -# Changes in HEAD +# Changes in 0.8.0 + +This is a stable bugfix and feature release. Major new features and changes include: ## Changes fixed as part of the switch to zle-line-pre-redraw From dcc99a86497491dfe41fb8b0d5f506033546a8c0 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Mon, 18 Dec 2023 16:07:39 -0600 Subject: [PATCH 05/10] Post-release version number bump. --- .version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.version b/.version index a3df0a6..d182dc9 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -0.8.0 +0.8.1-dev From e0165eaa730dd0fa321a6a6de74f092fe87630b0 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sat, 6 Jan 2024 12:33:41 -0600 Subject: [PATCH 06/10] main: Refactor __is_redirection Fixes #942. --- changelog.md | 7 ++ highlighters/main/main-highlighter.zsh | 7 +- .../main/test-data/redirection-all.zsh | 95 +++++++++++++++++++ 3 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 highlighters/main/test-data/redirection-all.zsh diff --git a/changelog.md b/changelog.md index bc6614d..8ee5088 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,10 @@ +# Changes in HEAD + + +- Highlight `&>` `>&|` `>&!` `&>|` and `&>!` as redirection. + [#942] + + # Changes in 0.8.0 This is a stable bugfix and feature release. Major new features and changes include: diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 54938b7..3ec96d9 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -254,10 +254,9 @@ _zsh_highlight_main__is_runnable() { _zsh_highlight_main__is_redirection() { # A redirection operator token: # - starts with an optional single-digit number; - # - then, has a '<' or '>' character; - # - is not a process substitution [<(...) or >(...)]. - # - is not a numeric glob <-> - [[ $1 == (<0-9>|)(\<|\>)* ]] && [[ $1 != (\<|\>)$'\x28'* ]] && [[ $1 != *'<'*'-'*'>'* ]] + # - is one of the tokens listed in zshmisc(1) + # - however (z) normalizes ! to | + [[ ${1#[0-9]} == (\<|\<\>|(\>|\>\>)(|\|)|\<\<(|-)|\<\<\<|\<\&|\&\<|(\>|\>\>)\&(|\|)|\&(\>|\>\>)(|\||\!)) ]] } # Resolve alias. diff --git a/highlighters/main/test-data/redirection-all.zsh b/highlighters/main/test-data/redirection-all.zsh new file mode 100644 index 0000000..e8ffb5d --- /dev/null +++ b/highlighters/main/test-data/redirection-all.zsh @@ -0,0 +1,95 @@ +#!/usr/bin/env zsh +# ------------------------------------------------------------------------------------------------- +# Copyright (c) 2024 zsh-syntax-highlighting contributors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted +# provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of +# conditions and the following disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors +# may be used to endorse or promote products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# ------------------------------------------------------------------------------------------------- +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et +# ------------------------------------------------------------------------------------------------- + +BUFFER=$': foo 9<>foo >foo 9>foo >|foo >\!foo >>foo >>|foo >>\!foo <<&9 <&- >&- <&p >&p >&foo &>foo >&|foo >&\!foo &>|foo &>\!foo >>&foo &>>foo >>&|foo >>&\!foo &>>|foo &>>\!foo' + +expected_region_highlight=( + '1 1 builtin' # : + '3 3 redirection' # < + '4 6 default' # foo + '8 9 redirection' # 9< + '10 12 default' # foo + '14 15 redirection' # <> + '16 18 default' # foo + '20 22 redirection' # 9<> + '23 25 default' # foo + '27 27 redirection' # > + '28 30 default' # foo + '32 33 redirection' # 9> + '34 36 default' # foo + '38 39 redirection' # >| + '40 42 default' # foo + '44 45 redirection' # >\! + '46 48 default' # foo + '50 51 redirection' # >> + '52 54 default' # foo + '56 58 redirection' # >>| + '59 61 default' # foo + '63 65 redirection' # >>\! + '66 68 default' # foo + '70 72 redirection' # <<< + '73 75 default' # foo + '77 78 redirection' # <& + '79 79 numeric-fd' # 9 + '81 82 redirection' # >& + '83 83 numeric-fd' # 9 + '85 86 redirection' # <& + '87 87 redirection' # - + '89 90 redirection' # >& + '91 91 redirection' # - + '93 94 redirection' # <& + '95 95 redirection' # p + '97 98 redirection' # >& + '99 99 redirection' # p + '101 102 redirection' # >& + '103 105 default' # foo + '107 108 redirection' # &> + '109 111 default' # foo + '113 115 redirection' # >&| + '116 118 default' # foo + '120 122 redirection' # >&\! + '123 125 default' # foo + '127 129 redirection' # &>| + '130 132 default' # foo + '134 136 redirection' # &>\! + '137 139 default' # foo + '141 143 redirection' # >>& + '144 146 default' # foo + '148 150 redirection' # &>> + '151 153 default' # foo + '155 158 redirection' # >>&| + '159 161 default' # foo + '163 166 redirection' # >>&\! + '167 169 default' # foo + '171 174 redirection' # &>>| + '175 177 default' # foo + '179 182 redirection' # &>>\! + '183 185 default' # foo +) From 5eb677bb0fa9a3e60f0eff031dc13926e093df92 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 21 Nov 2024 14:56:08 +0000 Subject: [PATCH 07/10] 'main' tests: Don't assume ps(1) is available. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's actually unavailable in the minimal chroots Debian builds our package on. That's allowed by POSIX, which specifies ps(1) to be optional, whereas id(1) — - is not optional in POSIX - should exist on every system anyone might run the testsuite on - has the same length name, so test expectations don't have to be updated - doesn't take a filename argument (ditto) That does make the pipeline as a whole somewhat nonsensical semantically, but it remains just as valid syntactically. --- highlighters/main/test-data/multiple-redirections.zsh | 2 +- highlighters/main/test-data/simple-redirection.zsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/highlighters/main/test-data/multiple-redirections.zsh b/highlighters/main/test-data/multiple-redirections.zsh index 778e712..1545c1b 100644 --- a/highlighters/main/test-data/multiple-redirections.zsh +++ b/highlighters/main/test-data/multiple-redirections.zsh @@ -27,7 +27,7 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='ps aux | grep java | sort | uniq | tail | head' +BUFFER='id bob | grep java | sort | uniq | tail | head' expected_region_highlight=( "1 2 command" # ps diff --git a/highlighters/main/test-data/simple-redirection.zsh b/highlighters/main/test-data/simple-redirection.zsh index e8c25e5..fb06f19 100644 --- a/highlighters/main/test-data/simple-redirection.zsh +++ b/highlighters/main/test-data/simple-redirection.zsh @@ -27,7 +27,7 @@ # vim: ft=zsh sw=2 ts=2 et # ------------------------------------------------------------------------------------------------- -BUFFER='ps aux | grep java' +BUFFER='id bob | grep java' expected_region_highlight=( "1 2 command" # ps From 1d85c692615a25fe2293bdd44b34c217d5d2bf04 Mon Sep 17 00:00:00 2001 From: Matthew Martin Date: Sun, 8 Feb 2026 10:48:48 -0600 Subject: [PATCH 08/10] main: precommand_options += caffeinate Closes #975 --- highlighters/main/main-highlighter.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index 3ec96d9..e6f5e35 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -372,6 +372,7 @@ _zsh_highlight_highlighter_main_paint() 'grc' :se # grc - a "generic colouriser" (that's their spelling, not mine) 'cpulimit' elp:ivz # cpulimit 0.2 'ktrace' fgpt:aBCcdiT + 'caffeinate' tw:dimsu # as of macOS's caffeinate(8) dated November 9, 2012 ) # Commands that would need to skip one positional argument: # flock From c4d95591843d49838b7ad30081e7aba3135a6703 Mon Sep 17 00:00:00 2001 From: Colin Kinloch Date: Mon, 23 Sep 2024 17:43:37 +0100 Subject: [PATCH 09/10] main: Add systemd run0 equivalent to sudo --- highlighters/main/main-highlighter.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/highlighters/main/main-highlighter.zsh b/highlighters/main/main-highlighter.zsh index e6f5e35..061e2a4 100644 --- a/highlighters/main/main-highlighter.zsh +++ b/highlighters/main/main-highlighter.zsh @@ -354,6 +354,7 @@ _zsh_highlight_highlighter_main_paint() 'pkexec' '' # doesn't take short options; immune to #121 because it's usually not passed --option flags # Not listed: -h, which has two different meanings. 'sudo' Cgprtu:AEHPSbilns:eKkVv # as of sudo 1.8.21p2 + 'run0' ugD:h # systemd 256.6 'stdbuf' ioe: 'eatmydata' '' 'catchsegv' '' From 2fc57d63067c18b1100ecdbf684fa5baf49459d1 Mon Sep 17 00:00:00 2001 From: Manish Tiwari Date: Fri, 21 Aug 2026 10:58:49 +0530 Subject: [PATCH 10/10] tests: fix relative links in tests/README.md test-highlighting.zsh and test-perfs.zsh were linked as tests/test-*.zsh, but this file already lives in tests/, so the links resolved to tests/tests/test-*.zsh and 404'd. Found by pointing a markdown link-checker at the repo. --- tests/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/README.md b/tests/README.md index eefeb54..10f399c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -86,7 +86,7 @@ grow ways to set `$PREBUFFER` to inject free-form code into the generated file. Highlighting test ----------------- -[`test-highlighting.zsh`](tests/test-highlighting.zsh) tests the correctness of +[`test-highlighting.zsh`](test-highlighting.zsh) tests the correctness of the highlighting. Usage: ```zsh @@ -110,7 +110,7 @@ results (tests that failed but were expected to succeed, or vice-versa), run Performance test ---------------- -[`test-perfs.zsh`](tests/test-perfs.zsh) measures the time spent doing the +[`test-perfs.zsh`](test-perfs.zsh) measures the time spent doing the highlighting. Usage: ```zsh