]> git.ipfire.org Git - thirdparty/vim.git/commit
syntax(sh): Improve the recognition of bracket expressions
authorAliaksei Budavei <0x000c70@gmail.com>
Mon, 30 Dec 2024 09:23:50 +0000 (10:23 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 30 Dec 2024 09:23:50 +0000 (10:23 +0100)
commit48fa3198b7118023fea4b15015a97c920887eb07
tree3d9d7a65e5e6c419125ad3c7cbe6c3edc546bcb8
parent6de7191c31941b8be46dcf81c0ab71ad1285ab66
syntax(sh): Improve the recognition of bracket expressions

- Define a general non-"contained" "shBracketExpr" group,
  and replace with it the "contained" bracket variant of
  "shOperator", adjusting the patterns for the competing
  conditional commands "[" and "[[".
- Accommodate some unbalanced brackets (e.g. "[!][!]").
- Make the leading "!" (or "^") stand out in NON-matching
  bracket expressions.
- Support literal newlines in parametric patterns (along
  with pathname globbings and "case" patterns).
- Also match bracket expressions in:
  * parametric patterns (e.g. "${1#[ab]_}");
  * pathname globbings (e.g. "[ab]*.txt");
  * arguments for the "[[", "echo", and "print" commands.
- Recognise collating symbols (e.g. "[.a.]") and equivalence
  classes (e.g. "[=a=]").
- Recognise end patterns for a pattern substitution form of
  parameter expansion and match bracket expressions in such
  patterns (e.g. "${1/%[.!]/;}").

fixes #15799
closes: #15941

References:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap09.html#tag_09_03_05
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_14
https://git.savannah.gnu.org/gitweb/?p=bash.git;a=blob_plain;f=doc/bash.html;hb=37b7e91d64ad10b1a1815d12128c9475636df670
http://www.mirbsd.org/htman/i386/man1/mksh.htm

Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
16 files changed:
runtime/syntax/sh.vim
runtime/syntax/testdir/dumps/sh_04_01.dump
runtime/syntax/testdir/dumps/sh_12_00.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_01.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_02.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_03.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_04.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_05.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_06.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_07.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_08.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_09.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_10.dump [new file with mode: 0644]
runtime/syntax/testdir/dumps/sh_12_11.dump [new file with mode: 0644]
runtime/syntax/testdir/input/sh_04.sh
runtime/syntax/testdir/input/sh_12.sh [new file with mode: 0644]