diff --git a/shdoc b/shdoc index 762e63d..f013e6c 100755 --- a/shdoc +++ b/shdoc @@ -939,7 +939,7 @@ match($0, /^([[:blank:]]*#[[:blank:]]+)@(stdin|stdout|stderr)[[:blank:]]+(.*[^[: # - `function function_name () {` # - `function_name () {` # - `function_name {` -/^[[:blank:]]*(function[[:blank:]]+)?([a-zA-Z0-9_\-:-\\.]+)[[:blank:]]*(\([[:blank:]]*\))?[[:blank:]]*\{*/ \ +/^[[:blank:]]*(function[[:blank:]]+)?([a-zA-Z0-9_\-:-\\.]+)[[:blank:]]*(\([[:blank:]]*\))?[[:blank:]]*[({]/ \ { process_function($0) function_declaration_complete = 1 @@ -955,7 +955,7 @@ match($0, /^([[:blank:]]*#[[:blank:]]+)@(stdin|stdout|stderr)[[:blank:]]+(.*[^[: } # Handle lone opening bracket if previous line is a function declaration. -/^[[:blank:]]*\{/ \ +/^[[:blank:]]*[({]/ \ && function_declaration != "" { debug("→ multi-line function declaration.") # Process function declaration. diff --git a/tests/testcases/@function-declaration.test.sh b/tests/testcases/@function-declaration.test.sh index 8ca2f65..b25359b 100644 --- a/tests/testcases/@function-declaration.test.sh +++ b/tests/testcases/@function-declaration.test.sh @@ -35,6 +35,35 @@ function g function h() { echo "h"; } +# @description Subshell Function n°1 +sa() ( + echo "a" +) + +# @description Subshell Function n°2 +sb() ( echo "b" ; ) + +# @description Subshell Function n°3 +:sc() ( echo "c"; ) + +# @description Subshell Function n°4 +sd-method() +( echo "d"; ) + +# @description Subshell Function n°5 +function se:function ( echo "e"; ) + +# @description Subshell Function n°6 +function sf() ( echo "f"; ) + +# @description Subshell Function n°7 +function sg +( echo "g"; ) + +# @description Subshell Function n°8 +function sh() +( echo "h"; ) + a b :c @@ -43,6 +72,15 @@ e:function f g h + +sa +sb +:sc +sd-method +se:function +sf +sg +sh EOF tests:put expected <