bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

``shopt -s extglob'' and ``function @() { true; }''


From: Clark Wang
Subject: ``shopt -s extglob'' and ``function @() { true; }''
Date: Fri, 31 Mar 2017 12:00:28 +0800

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-expanded for function @(). This looks kind of counter-intuitive to me.

Bug or feature?

-clark

‚Äč

reply via email to

[Prev in Thread] Current Thread [Next in Thread]