Skip to content

[zsh] misc. issues #4244

@okdana

Description

@okdana

What happened?

i've finally started using the new zsh highlighting (current master), which is very nice, but i've noticed a few issues, some of which can break the entire file. i'm not able to study the definitions myself atm so i'll just document them for now:

  • 1. this is highlighted as a command, but it should be a parameter assignment [ZSH] Fix parameter identifier pattern #4245

    1=foo
  • 2. it highlights expansion flag arguments as if they're in the normal context where expansion, substitution, etc are valid (and therefore they have to follow those rules). but they're not. flag arguments are always literals, except in the presence of (p) where a limited form of parameter expansion is allowed (${(pj<$j>)arr}) [ZSH] Fix expansion in parameter expansion flags #4246

    : ${(j<$j>)arr} ${(j<$(ls)>)arr} ${(j<${>)arr}
  • 3. it treats everything within an array subscript as arithmetic, so subscript flags are not highlighted, glob syntax is marked as invalid, etc. this means it doesn't even like plain strings used as association keys. this is a big one for a lot of shell code shipped with zsh [ShellScript] Add Zsh subscript flags #4273

    : ${arr[(r)([^@]##@|)foo]}
    : ${assoc[my.key]}
  • 4. i guess it wants everything after autoload to be a literal function name so it doesn't highlight paths correctly and it breaks completely on globs [ZSH] Fix globs in autoload arguments #4247

    autoload /path/to/func
    autoload $dir/*/*~*.zwc(#q.N:t)
  • 5. i think it doesn't know that q- and q+ are variants of q, not pairs of separate flags, and since + isn't a valid flag on its own it's not highlighted right [ZSH] Fix expansion in parameter expansion flags #4246

    : ${(q-)foo} ${(q+)foo}
  • 6. doesn't seem to like dynamically named functions, nor functions with quoted/escaped names, nor multi defs, unless they're preceded by function [ZSH] Fix function definition identifiers #4262

    $foo() { : }
    \$foo() { : }
    'foo'() { : }
    foo bar() { : }
  • 7. the parameter name fd is highlighted as a command
    (WONTFIX, working as expected)

    exec {fd}>&-
  • 8. it doesn't like multiple parameter names taken in a for loop. it highlights y as a command so i assume it's trying to handle the short for syntax. taking multiple parameters is much more common and useful i think so if it's too hard to distinguish them, imo, the choice is clear [ZSH] Fix for-loops with multiple variables #4248

    for x y z in a b c; do :; done
  • 9. it doesn't like end braces in unquoted string literals [ZSH] Ensure balanced braces in shell words #4286

    echo {foo}
  • 10. when the flag argument delimeter is . and the last argument is numeric, i guess it can't figure out where it ends. not a problem with another delimiter, or when the second argument is present, or when it's a flag like (j) that it knows takes an arbitrary string [ZSH] Fix glob flag argument bailout #4275

    : ${(j.12.)foo}   # ok
    : ${(r.12.x.)foo} # ok
    : ${(r.12.)foo}
  • 11. it doesn't like # or ## in arithmetic (both expand to a character value)
    [ZSH] Add operator for numeric representation of characters #4252

    : $(( #chr ))
    : $(( ##chr ))
  • 12. it seems to treat all history modifiers as arithmetic (maybe carried over from bash, where : precedes an offset), so most of them get highlighted as parameter names, which can be easy to miss. but the # thing exposes the problem [ZSH] Fix qualifier and expansion modifiers #4307

    : ${foo:h} ${foo:&} ${foo:t2}  
    : ${foo:s/#x/X} ${foo:s/#%x/X}
  • 13. the fact that it highlights alias commands as if they were in normal context means they have to be valid on their own. this might be too esoteric to worry about tbh. but i noticed it in a file so mentioning anyway

    wontfix

    alias OPEN='{' CLOSE='};'
  • 14. doesn't handle function options very well, especially with anonymous functions [ZSH] Fix function definition flags #4249

    function -T { : }
    function -T () { : }
    function -- -T { : }
  • 15. doesn't handle certain patterns to typeset/unset -m [ShellScript] Fix declare/typeset/unset variable assignments #4266

    typeset -m \*
    unset -m \*a
    unset -m a\* # ok
  • 16. doesn't handle command-less redirects inside =( ) (but <( ) is ok) [ZSH] Fix compound equal expansions #4263

    cat =( < foo )
    cat =( <<< foo )

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: SyntaxT: bugA bug in an existing language feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions