On Sunday 02 June 2013 03:16:53 Michał Górny wrote: > Dnia 2013-06-02, o godz. 03:09:31 Mike Frysinger napisał(a): > > On Sunday 02 June 2013 02:51:34 Michał Górny wrote: > > > Dnia 2013-06-01, o godz. 23:03:20 Mike Frysinger napisał(a): > > > > simple set of helpers to save/restore a variable in a limited section > > > > of code > > > > > > > > you can see an example of it in action at the end of the file where i > > > > need to tweak epatch (and no, doing `LC_COLLATE=C set -- ....` does > > > > not work). > > > > > > Why the ugly hackery instead of proper 'local' scope? > > > > there's no way to undo the local thus it affects the rest of the func. > > this makes sure the change is actually localized to where it is needed. > > By use of global variables and a bunch of additional code and evals.
the implementation details of estack_* doesn't matter
> Is:
>
> local _epatch_foo=${foo}
> local foo
> ...
> foo=${_epatch_foo}
>
> really that hurtful?
except you aren't handling edge cases (like set vs unset), and i've replicated
this pattern before (in fact, you've filed bugs where the set/unset case wasn't
handled). API 101: implement it once correctly to simplify everyone else.
> Also, do you really want the collation to be changed only in this one
> place? This looks weird to me.
yes, i only want to force it here, because it's the only place where collation
matters in the func currently.
> Much like fixing tiny bug and trying to
> avoid checking whether anything else is affected.
yeah, because forcing specific behavior for an entire function is always the
correct answer. it's like telling people to export LC_ALL=C in make.conf so
they never hit locale related problems.
feel free to read the whole func yourself if you think there are other places
where this matters.
-mike
signature.asc
Description: This is a digitally signed message part.
