[Top][All Lists]

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

Re: [Help-bash] make function local

From: Eduardo A . Bustamante López
Subject: Re: [Help-bash] make function local
Date: Sun, 12 Apr 2015 16:56:57 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

Oh, you already have lots of things to do to bother with this :-)

Anyways, I'll expand them.

On Fri, Apr 10, 2015 at 04:35:25PM -0400, Chet Ramey wrote:
> On 4/10/15 10:13 AM, Eduardo A. Bustamante López wrote:
> > - a faster implementation of the variable lookup code
> What does this mean, exactly?  Optimizing the existing code paths? (Have at
> it.)  Different semantics?  Static as opposed to dynamic scoping?

Yes. I've been using gprof to study the code paths of some basic functions, and
it seems like it spends quite some time in the find_variable() and related
functions (IIRC, there was an mt_hash or something function taking up some
precious time). I'm not sure if it might be better to have other kind of data
structure for this. TBH, I'm not sure if there's even enough justification for
this, other than to make bash startup faster.

> > - a shopt to disable evaluation of shell code in places like arithmetic
> > expansion

Remember this thread?

At one point, this was brought up:

address@hidden ~/t % bash -c 'var="a[\$(ls)]"; a=(); a[var]=x; declare -p a' 
bash: bar baz foo: syntax error in expression (error token is "baz foo")

I understand the reasons behind it. This time I don't want to debate that :-)
But, wouldn't it be nice to have a `arith_expand' or something shopt that when
turned off, this happened:

bash +O arith_expand -c 'var="a[\$(ls)]"; a=(); a[var]=x; declare -p a'
declare -a a='([0]="x")'

More or less how awk treats non-numeric strings as zero.

Eduardo Bustamante

reply via email to

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