On Fri, Mar 31, 2017 at 7:00 AM, Clark Wang <dearv...@gmail.com> wrote:

> There is a post on stackoverflow: http://stackoverflow.com/
> questions/43117707/bashs-strange-behavior-on-a-function-named/
>
> The *problem*:
>
> bash-4.4# shopt -s extglob
> bash-4.4# function @() { echo foo; }
> bash-4.4# @()
> foo
> bash-4.4# declare -f
> @() ()
> {
>     echo foo
> }
> bash-4.4#
> bash-4.4# unset -f '@()'
> bash-4.4#
> bash-4.4# shopt -s nullglob
> bash-4.4# function @() { echo foo; }
> bash-4.4# @()
> bash-4.4# declare -f
> @() ()
> {
>     echo foo
> }
> bash-4.4#
>
> So when extglob is on, @() is handled as a glob pattern which makes
> sense. But the behavior after shopt -s nullglob indicates that the glob
> pattern @() is not *filename-expand*ed for function @(). This looks kind
> of counter-intuitive to me.
>
> Bug or feature?
>
> -clark
>


> ​
>
Since the manual does not document special chars as allowed in function
names, it can be whatever :D

"function" is a keyword not a builtin, so it can change the rules of
parsing, like trying to parse a function name instead of performing the
normal expansions (that's also why you can't do things like  var=foo;
function $var { echo foo; } )

 I'm more surprised that @() runs the function at all. (It seems to hang my
4.3 bash here)

Reply via email to