I cannot define a bash function only for specific names and when I use <function name>() syntax and when I try to define it in the current shell (i.e. not in a subshell).
$ 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; }'
What's happening here? Is this an expected behavior? I believe, at least, this is not syntax error near unexpected token `(' as the error message suggests.
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.
function make { echo bar; }; make() { echo foo; }; make --versionat the command line and as expected, get"foo"back, so I'm a bit confused as to your error. SameGNU bash, version 5.0.16(1)-release (x86_64-pc-linux-gnu)GNU bash, version 5.0.3(1)-release (arm-unknown-linux-gnueabihf)on Raspberry Pi 3. So maybe the problem is due to my configuration but is it possible to customize bash not to accept specific names in the first place? I haven't modified the source code of bash.sourceas the search term, I can't find anything there that explains it either.