Files
Aliaksei Budavei 9c0d057e3d runtime(sh): Improve the matching of function definitions
- Drop the remaining undefined "shFunctionStart" references
  (gone in v7.2b.000, c236c16d0).
- Revise nestable contexts where function definitions are
  supported:
  * Stop looking for function definitions in arithmetic
    expressions.
  * Recognise function definitions enclosing other function
    definitions.
- In addition to grouping commands "{}" and "()", also match
  other compound commands (e.g. "if"; see "shFunctionCmd*")
  whenever these commands are supported as complete function
  bodies.
- Balance body delimiters "(" and ")" for "shFunctionFour"
  in Bash; match such function bodies whenever the use of
  the function parameter list "()" token is optional, i.e.
  when the "function" reserved word is present.
- Enable the use of "shFunctionFour" definitions.
- Do not claim optional leading whitespace characters before
  a matched function definition.
- Prefer patterns with ASCII atoms (e.g. "\h") to equivalent
  collections (e.g. "[A-Za-z_]") for speed.
- Accommodate word-boundary assertions in function name
  patterns to names that may start and/or end with supported
  non-word characters, e.g. "@test:".
- Match more valid function names in Bash: non-ASCII names,
  non-word names.
- Allow for function names with "do", "done", etc. prefixes;
  confine these name checks to "shDoError" and "shIfError".

fixes:   #19619
related: #19638

References:
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_09_04
https://gitweb.git.savannah.gnu.org/gitweb/?p=bash.git;a=blob_plain;f=doc/bash.html;hb=637f5c8696a6adc9b4519f1cd74aa78492266b7f
https://web.archive.org/web/20151105130220/http://www.research.att.com/sw/download/man/man1/ksh88.html
https://web.archive.org/web/20151025145158/http://www2.research.att.com/sw/download/man/man1/ksh.html
http://www.mirbsd.org/htman/i386/man1/mksh.htm

Co-authored-by: Johnothan King <johnothanking@protonmail.com>
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Aliaksei Budavei <0x000c70@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2026-03-24 20:35:48 +00:00

21 lines
1.9 KiB
Bash
Generated

| +0#0000e05#a8a8a8255@1>#+0&#ffffff0|!|/|b|i|n|/|b|a|s|h| +0#0000000&@61
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |s|e|t|l|o|c|a|l| |f|e|n| |f|d|c|=|2| |f|d|l|=|8| |f|d|m|=|s|y|n|t|a|x| +0#0000000&@20
| +0#0000e05#a8a8a8255@1|#+0&#ffffff0| |V|I|M|_|T|E|S|T|_|S|E|T|U|P| |l|e|t| |g|:|s|h|_|f|o|l|d|_|e|n|a|b|l|e|d| |=| |1| |+| |2| |+| |4| +0#0000000&@22
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1|t+0#af5f00255#ffffff0|y|p|e|s|e|t| +0#0000000&|-+0#e000e06&|i| +0#0000000&|n+0#00e0e07&|=+0#0000000&|0+0#e000002&| +0#0000000&@58
| +0#0000e05#a8a8a8255@1|d+0#00e0e07#ffffff0|o@1|s|i|e|(|)| +0#0000000&|(+0#e000e06&@1|n+0#0000000&|++0#af5f00255&|=|1+0#e000002&|)+0#e000e06&@1|;+0#0000000&| |d|o@1|s|i|e| @47
| +0#0000e05#a8a8a8255@1|d+0#00e0e07#ffffff0|o|n|e@1|(|)| +0#0000000&|[+0#e000e06&@1| +0#0000000&|-+0#af5f00255&|n| +0#0000000&|$+0#e000e06&|#| +0#0000000&|]+0#e000e06&@1|;+0#0000000&| |d|o|n|e@1| @46
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1|t+0#00e0e07#ffffff0|h|e|n|c|e|(|)| +0#0000000&@64
| +0#0000e05#a8a8a8255@1|u+0#af5f00255#ffffff0|n|t|i|l| |:| +0#0000000&@65
|-+0#0000e05#a8a8a8255| |d+0#af5f00255#ffffff0|o| +0#0000000&@70
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|:| @67
||+0#0000e05#a8a8a8255| |d+0#af5f00255#ffffff0|o|n|e| +0#0000000&@68
| +0#0000e05#a8a8a8255@1|t+0#0000000#ffffff0|h|e|n|c|e| @66
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1|w+0#00e0e07#ffffff0|h|i|l|e|s|(|)| +0#0000000&|w+0#af5f00255&|h|i|l|e| |f|a|l|s|e|;| |d|o| +0#0000000&|:|;+0#af5f00255&| +0#0000000&|d+0#af5f00255&|o|n|e|;+0#0000000&| |w|h|i|l|e|s| @32
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|-+0#0000e05#a8a8a8255| |e+0#00e0e07#ffffff0|l|s|e|w|h|e|r|e|(|)| +0#0000000&|i+0#af5f00255&|f| |:+0#0000000&| @56
|i|s|_|b|a|s|h|:| |1|,| @45|1|,|1| @10|T|o|p|