Я не могу определить bash функцию только для специфицированных c имен и когда я использую синтаксис <function name>()
и когда я пытаюсь определить это в текущей оболочке (т.е. не в подоболочке).
$ cat -n test.sh
1 function f { true; }
2
3 f() { true; }
4
5 function make { true; }
6
7 make() { true; }
$ function f { true; } && f() { true; } #OK
$ function make { true; } && make() { true; } #NG
bash: syntax error near unexpected token `(`
$ bash test.sh #OK
$ source test.sh #NG
bash: test.sh: line 7: syntax error near unexpected token `(`
bash: test.sh: line 7: `make() { true; }'
Что здесь происходит? Это ожидаемое поведение? По крайней мере, я считаю, что это не синтаксическая ошибка рядом с неожиданным токеном `(', как следует из сообщения об ошибке.
Environment
$ bash --version
GNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.