[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] declare -f <name> fails for valid function name in Bash 4.2.
From: |
Steve Amerige |
Subject: |
[Help-bash] declare -f <name> fails for valid function name in Bash 4.2.46(2)-release |
Date: |
Mon, 14 May 2018 06:08:46 -0400 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 |
I have code that implements an object-oriented array "class" in Bash.
One of the functions is named object:[.
The problem I'm encountering is that doing declare -f 'object:[' emits
an error.
Here is a demonstration of the problem:
object:[()
{
echo 'Function works'
}
% object:[
Function works
%
% declare -f 'object:['
bash: declare: `object:[': not a valid identifier
%
The function can be declared and invoked without any problems. The only
issue is that declare -f object:[ fails. I've tried escaping the
backslash and various quoting, but I have not been able to get declare
-f to work as expected.
I do note that if type just declare -f without a function name, then I
do see in the output the function as declared above.
I have tested with identical failures as shown above in each case using
the following Bash versions:
- GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
- GNU bash, version 4.3.30(1)-release (x86_64-unknown-linux-gnu)
- GNU bash, version 4.4.18(1)-release (x86_64-unknown-linux-gnu)
Is this a bug in Bash? Is there any workaround?
My Bash version is: GNU bash, version 4.2.46(2)-release
(x86_64-redhat-linux-gnu).
I'm on an up-to-date CentOS 7.4 OS.
I'm not invoking Bash in POSIX mode.
Thanks,
Steve Amerige
P.S. I found the following. Are any of them indicative of the same or
related problems?
% cd ~/src/bash-4.4.18/tests
% grep -r 'declare.*not a valid identifier'
array.right:./array2.sub: line 1: declare: `[]=asdf': not a valid
identifier
assoc.right:./assoc5.sub: line 13: declare: `myarray[foo[bar]=bleh':
not a valid identifier
nameref.right:./nameref11.sub: line 4: declare: `/': not a valid
identifier
nameref.right:./nameref11.sub: line 24: declare: `': not a valid
identifier
nameref.right:./nameref12.sub: line 26: declare: `42': not a valid
identifier
nameref.right:./nameref12.sub: line 45: declare: `7*6': not a valid
identifier
errors.right:./errors.tests: line 60: declare: `-z': not a valid
identifier
errors.right:./errors.tests: line 61: declare: `/bin/sh': not a valid
identifier
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-bash] declare -f <name> fails for valid function name in Bash 4.2.46(2)-release,
Steve Amerige <=