[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: differences in Q.-removal, var-expansion and allowed characters in f
From: |
Linda Walsh |
Subject: |
Re: differences in Q.-removal, var-expansion and allowed characters in fn & var names |
Date: |
Sun, 10 Jan 2016 12:50:55 -0800 |
User-agent: |
Thunderbird |
Andreas Schwab wrote:
That's not the same statement. The same statement would be
def='function $fn () { echo $fn ; }'
I know what you mean, but,
Yeah, sorta but I want it to do variable expansion AND quote removal.
I.e. using a var or DQ of the object-name, "a", works in declare.
Work ok:
> declare a=1 # OR
> declare "a"=1 and declare 'a'=1 # OR
> declare 'a=1' and declare "a=1" # OR
> x=a
> declare $x=1 # OR
> declare "$x"=1 and declare "$x=1" # All "work"
With eval, I can use:
> eval declare a=1, eval 'declare a=1' or eval "declare a=1"
> x=a &&
> eval declare $x=1 eval 'declare $x=1' or eval "declare $x=1"
But w/functions, none of the 1st group will work
Vs. w/function, only
> eval 'function a { echo fna; }' # OR
> eval "function a { echo fna; }" # OR
> x=a # AND w/eval: only whole statements:
> eval 'function $x { echo fn$x; }' # OR
> eval "function $x { echo fn$x; }" # work.
None of the partial- or no- quote forms work.
While quoting rules for "Identifier Names" used w/"declare" are more
flexible/tolerant than those used for "functions", the *opposite*
is true for what characters are allowed in "function names" v.
"varnames". I.e names for functions allow UTF-8 but names
for variables do not. Using a name with a Greek alpha + a Roman '4':
> declare ɑⅣ=1 # doesn't work
-bash: declare: `ɑⅣ=1': not a valid identifier
> function ɑⅣ { echo fn_ɑⅣ; } # same name used for
func
> ɑⅣ
fn_ɑⅣ # UTF8 ok in fn-names
But this seems like it shouldn't work (number before the alpha):
> function Ⅳɑ { echo fn_Ⅳɑ; } # function "4a"
> Ⅳɑ
fn_Ⅳɑ
Even though the allowed characters for a "variable" Name are the
same as the characters allowed for "function" names. Why the
differences (in both cases?), also should a func starting with
a number be allowed in function names?
-l
- 'official function declaration format' doesn't work if alias defined, Linda Walsh, 2016/01/06
- Re: 'official function declaration format' doesn't work if alias defined, Greg Wooledge, 2016/01/07
- Re: 'official function declaration format' doesn't work if alias defined, Reuti, 2016/01/07
- Re: aliases v. functions; command extension? (-f & -F)?, Linda Walsh, 2016/01/08
- doesn't bash do variable subst. or quote removal on function statement, Linda Walsh, 2016/01/09
- Re: doesn't bash do variable subst. or quote removal on function statement, Andreas Schwab, 2016/01/10
- Re: differences in Q.-removal, var-expansion and allowed characters in fn & var names,
Linda Walsh <=
- Re: differences in Q.-removal, var-expansion and allowed characters in fn & var names, Chet Ramey, 2016/01/11
- Re: doesn't bash do variable subst. or quote removal on function statement, Chet Ramey, 2016/01/11
- Re: doesn't bash do variable subst. or quote removal on function statement, Linda Walsh, 2016/01/12
- Re: doesn't bash do variable subst. or quote removal on function statement, Greg Wooledge, 2016/01/12
- Re: doesn't bash do variable subst. or quote removal on function statement, Linda Walsh, 2016/01/12
- Re: doesn't bash do variable subst. or quote removal on function statement, Chet Ramey, 2016/01/13
- Re: doesn't bash do variable subst. or quote removal on function statement, Linda Walsh, 2016/01/13
- Re: doesn't bash do variable subst. or quote removal on function statement, Chet Ramey, 2016/01/13
- Re: doesn't bash do variable subst. or quote removal on function statement, Chet Ramey, 2016/01/13
- Re: aliases v. functions; command extension? (-f & -F)?, Chet Ramey, 2016/01/11