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
2.1 KiB
Plaintext
Generated

||+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
||+0#0000e05#a8a8a8255| |t+0#af5f00255#ffffff0|h|e|n| +0#0000000&|:|;+0#af5f00255&| +0#0000000&|f+0#af5f00255&|i|;+0#0000000&| |e|l|s|e|w|h|e|r|e| @51
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
|-+0#0000e05#a8a8a8255| |s+0#00e0e07#ffffff0|e|l|e|c|t|o|r|(|)| +0#0000000&|s+0#af5f00255&|e|l|e|c|t| |x+0#0000000&| |i+0#af5f00255&|n| +0#0000000&|1+0#e000002&| +0#0000000&|2+0#e000002&|;+0#0000000&| |d+0#af5f00255&|o| +0#0000000&@42
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|b+0#af5f00255&|r|e|a|k| +0#0000000&@63
||+0#0000e05#a8a8a8255| |d+0#af5f00255#ffffff0|o|n|e| +0#0000000&@68
| +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|e|l|e|c|t|o|r| |0+0#e000002&|<+0#af5f00255&|/+0#0000000&|d|e|v|/|n|u|l@1| |2+0#e000002&|>+0#af5f00255&|/+0#0000000&|d|e|v|/|n|u|l@1| ||@1| |:| @35
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1|c+0#00e0e07#ffffff0|a|s|e|d|(|)| +0#0000000&|c+0#af5f00255&|a|s|e| +0#0000000&|"+0#af5f00255&|$+0#e000e06&|#|"+0#af5f00255&| +0#0000000&|i+0#af5f00255&|n| +0#0000000&|*|)+0#af5f00255&| +0#0000000&|:|;+0#af5f00255&@1| +0#0000000&|e+0#af5f00255&|s|a|c|;+0#0000000&| |c|a|s|e|d| @33
| +0#0000e05#a8a8a8255@1| +0#0000000#ffffff0@72
| +0#0000e05#a8a8a8255@1|f+0#00e0e07#ffffff0|o|r|e|(|)| +0#0000000&@66
| +0#0000e05#a8a8a8255@1|f+0#af5f00255#ffffff0|o|r| +0#0000000&|x| |i+0#af5f00255&|n| +0#0000000&|1+0#e000002&| +0#0000000&|2+0#e000002&| +0#0000000&@60
|-+0#0000e05#a8a8a8255| |d+0#af5f00255#ffffff0|o| +0#0000000&@70
||+0#0000e05#a8a8a8255| | +0#0000000#ffffff0@3|:+0#0000e05&| +0#0000000&@67
@57|1|9|,|1| @9|5|0|%|