[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
doesn't bash do variable subst. or quote removal on function statement
From: |
Linda Walsh |
Subject: |
doesn't bash do variable subst. or quote removal on function statement |
Date: |
Sat, 09 Jan 2016 17:28:10 -0800 |
User-agent: |
Thunderbird |
Reuti wrote:
Am 08.01.2016 um 21:36 schrieb Piotr Grzybowski:
hello Linda,
On Fri, Jan 8, 2016 at 9:14 PM, Linda Walsh <bash@tlinx.org> wrote:
For what it's worth, It might be useful to have something like
'command' [..]
that would be useful, a keyword like:
function p params;
But 'function p'... is already a lead-in to a function definition, i.e:
function xyz { :; } #(create function foo)
AFAICS putting the name in quotes (single or double) will prefer the function
over the alias, but it will fall back to a command if there is no function.
'P' params
----
Not in a function definition (i.e. this is broken AFAIAC in bash).
I.e.
'func' () { :; }
-bash: `'func'': not a valid identifier
function 'func' () { : ; }
-bash: `'func'': not a valid identifier
function "func" () { :; }
-bash: `"func"': not a valid identifier
---
That's weird. while, _maybe_ I could see the 1st one not working
if looking for a bash keyword, but the 2nd & third forms seems odd.
I thought variable substitution and quote-removal was supposed
to happen before the statement is executed ??
I.e.: this _seems_ broken:
shopt -s expand_aliases; alias my=declare
declare fn=myfunc ## function name in variable
doesn't work
function $fn { echo $fn ; }
-bash: `$fn': not a valid identifier
my -pf myfunc
-bash: declare: myfunc: not found
def="function $fn () { echo $fn ; }" ## but same statement, eval'd works
eval $def
my -f myfunc
myfunc ()
{
echo myfunc
}
I.e. while having the function name in a variable doesn't work
interactively, it does work when used with eval.
- '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 <=
- 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, 2016/01/10
- 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