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>
This commit is contained in:
committed by
Christian Brabandt
parent
6de7191c31
commit
48fa3198b7
20
runtime/syntax/testdir/dumps/sh_12_11.dump
Normal file
20
runtime/syntax/testdir/dumps/sh_12_11.dump
Normal file
@ -0,0 +1,20 @@
|
||||
| +0&#ffffff0@74
|
||||
|n+0#00e0e07&|l|=+0#0000000&|'+0#af5f00255&| +0#0000000&@70
|
||||
|'+0#af5f00255&| +0#0000000&@73
|
||||
|e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|"+0#af5f00255&|$+0#e000e06&|{|n|l|}|"+0#af5f00255&|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&|;+0#0000000&| |e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|'+0#0000000&|$|{|n|l|}|'|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&| +0#0000000&@14
|
||||
|e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|\+0#0000000&|"|$|{|n|l|}|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&|;+0#0000000&| |e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|\+0#0000000&|'|$|{|n|l|}|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&| +0#0000000&@14
|
||||
>e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|$+0#0000000&|{|n|l|}|\|"|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&|;+0#0000000&| |e+0#af5f00255&|c|h|o| +0#e000002&|"+0#af5f00255&|$+0#e000e06&|{|1|#+0#af5f00255&|$+0#e000e06&|{|1|%+0#af5f00255&@1|[+0#00e0003&|!+8#e000e06&|$+0#0000000&|{|n|l|}|\|'|]+0#00e0003&|*+0#0000000&|}+0#e000e06&@1|"+0#af5f00255&| +0#0000000&@14
|
||||
@75
|
||||
|b+0#00e0e07&|i|n|s|=+0#0000000&|(+0#e000e06&|)|;+0#0000000&| |b+0#00e0e07&|i|n|s|=+0#0000000&|(+0#e000e06&|0+0#e000002&| +0#0000000&|1+0#e000002&|)+0#e000e06&|;+0#0000000&| |e+0#af5f00255&|v|a|l| +0#0000000&|b+0#00e0e07&|i|n|s|++0#0000000&|=|(+0#e000e06&|{|0+0#e000002&|.+0#0000000&@1|1+0#e000002&|}+0#e000e06&|)| +0#0000000&@34
|
||||
|b+0#00e0e07&|i|n|s|[+0#e000e06&|0+0#e000002&|]+0#e000e06&|=+0#0000000&|0+0#e000002&|;+0#0000000&| |b+0#00e0e07&|i|n|s|[+0#e000e06&|1+0#e000002&|]+0#e000e06&|=+0#0000000&|1+0#e000002&|;+0#0000000&| |e+0#af5f00255&|v|a|l| +0#0000000&|b+0#00e0e07&|i|n|s|++0#0000000&|=|(+0#e000e06&|\+0#0000000&|$+0#e000e06&|{|b|i|n|s|[|{|1+0#e000002&|.+0#0000000&@1|0+0#e000002&|}+0#e000e06&|]|}|)|;+0#0000000&| |u+0#af5f00255&|n|s|e|t| +0#00e0e07&|b|i|n|s|[+0#e000e06&|3+0#e000002&|]+0#e000e06&| +0#00e0e07&|b|i|n|s|[+0#e000e06&|2+0#e000002&|]+0#e000e06&| +0#0000000&
|
||||
|b+0#00e0e07&|i|n|s|=+0#0000000&|(+0#e000e06&|[+0#00e0e07&|8+0#e000002&|#|0|]+0#00e0e07&|=+0#0000000&|$+0#e000e06&|(@1|2+0#e000002&|#|1|0@1|)+0#e000e06&@1| +0#0000000&|[+0#00e0e07&|$+0#e000e06&|(@1|8+0#e000002&|#|1|)+0#e000e06&@1|]+0#00e0e07&|=+0#0000000&|$+0#e000e06&|(@1|2+0#e000002&|#|1|0|)+0#e000e06&@1| +0#0000000&|[+0#00e0e07&|3+0#e000002&|]+0#00e0e07&|=+0#0000000&|$+0#e000e06&|{|b|i|n|s|[|2+0#e000002&|#|1|]+0#e000e06&|}| +0#0000000&|$+0#e000e06&|{|b|i|n|s|[|0+0#e000002&|]+0#e000e06&|}|)| +0#0000000&@2
|
||||
|(+0#e000e06&|e+0#af5f00255&|c|h|o| +0#e000002&|s|u|m|[+0#e000e06&|$|(@1|b|i|n|s|[|1+0#e000002&|6|#|3|]+0#e000e06&| |+| |b|i|n|s|[|8+0#e000002&|#|2|]+0#e000e06&| |+| |b|i|n|s|[|2+0#e000002&|#|1|]+0#e000e06&| |+| |b|i|n|s|[|0+0#e000002&|]+0#e000e06&|)@1|]|)| +0#0000000&@13
|
||||
|e+0#af5f00255&|v|a|l| +0#0000000&|u+0#af5f00255&|n|s|e|t| +0#00e0e07&|b|i|n|s|[+0#e000e06&|{|0+0#e000002&|.+0#0000000&@1|$+0#e000e06&|(@1|$|{|#|b|i|n|s|[|*+0#0000000&|]+0#e000e06&|}| |-| |1+0#e000002&|)+0#e000e06&@1|}|]| +0#0000000&@32
|
||||
|:| @73
|
||||
|~+0#4040ff13&| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
|~| @73
|
||||
| +0#0000000&@56|1|9@1|,|1| @8|B|o|t|
|
||||
Reference in New Issue
Block a user