Skip to content

Commit 936bc25

Browse files
committed
'main': The optimized cmdsubst input syntax doesn't glob.
Fixes #582.
1 parent c699ce9 commit 936bc25

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
- Fix `exec 2>&1;` being highlighted as an error.
3030
[#676]
3131

32+
- Fix `: $(<*)` being highlighted as globbing.
33+
[#582]
34+
3235
# Changes in version 0.7.1
3336

3437
- Remove out-of-date information from the 0.7.0 changelog.

highlighters/main/main-highlighter.zsh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ _zsh_highlight_main_highlighter_highlight_list()
498498
else
499499
args=(${(z)buf})
500500
fi
501+
502+
# Special case: $(<*) isn't globbing.
503+
if [[ $braces_stack == 'S' ]] && (( $+args[3] && ! $+args[4] )) && [[ $args[3] == $'\x29' ]] &&
504+
[[ $args[1] == *'<'* ]] && _zsh_highlight_main__is_redirection $args[1]; then
505+
highlight_glob=false
506+
fi
507+
501508
while (( $#args )); do
502509
arg=$args[1]
503510
shift args
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env zsh
2+
# -------------------------------------------------------------------------------------------------
3+
# Copyright (c) 2018 zsh-syntax-highlighting contributors
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without modification, are permitted
7+
# provided that the following conditions are met:
8+
#
9+
# * Redistributions of source code must retain the above copyright notice, this list of conditions
10+
# and the following disclaimer.
11+
# * Redistributions in binary form must reproduce the above copyright notice, this list of
12+
# conditions and the following disclaimer in the documentation and/or other materials provided
13+
# with the distribution.
14+
# * Neither the name of the zsh-syntax-highlighting contributors nor the names of its contributors
15+
# may be used to endorse or promote products derived from this software without specific prior
16+
# written permission.
17+
#
18+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19+
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20+
# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24+
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25+
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
# -------------------------------------------------------------------------------------------------
27+
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
28+
# vim: ft=zsh sw=2 ts=2 et
29+
# -------------------------------------------------------------------------------------------------
30+
31+
# See getoutput() and getoutputfile() in zsh's C source code.
32+
33+
BUFFER=$': $(<*)'
34+
35+
expected_region_highlight=(
36+
'1 1 builtin' # :
37+
'3 7 default' # $(<*)
38+
'3 7 command-substitution-unquoted' # $(<*)
39+
'3 4 command-substitution-delimiter-unquoted' # $(
40+
'5 5 redirection' # <
41+
'6 6 default' # * - not globbing!
42+
'7 7 command-substitution-delimiter-unquoted' # )
43+
)

0 commit comments

Comments
 (0)