bug-bash
[Top][All Lists]
Advanced

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

Re: conditional aliases are broken


From: Pierre Gaston
Subject: Re: conditional aliases are broken
Date: Thu, 18 Aug 2011 10:08:38 +0300

On Thu, Aug 18, 2011 at 6:46 AM, Linda Walsh <coreutils@tlinx.org> wrote:
>
>
>
> ` Eric Blake wrote:
>>
>> On 08/15/2011 04:40 PM, Sam Steingold wrote:
>>>>
>>>> * Andreas Schwab<fpujno@yvahk-z68x.bet>  [2011-08-15 22:04:04 +0200]:
>>>> Sam Steingold<sds@gnu.org>  writes:
>>>>>
>>>>> Cool.  Now, what does this imply?
>>>>
>>>>    "For almost every purpose, shell functions are preferred over
>>>> aliases."
>>>
>>> so, how do I write
>>> alias a=b
>>> as a function?
>>> (remember that arguments may contain spaces&c)
>>
>> a() { b "$@"; }
>
> ---
> Way too easy.
> how do you declare a variable for storage in the context of the caller?
> (using a function)...
> ???
>
> The DebugPush & DebugPop routines I used needed to store
> the current func's flags in it's context -- I found it very troublesome
> inside a function, to store a value into a local variable in the caller.

Is this a question? or are you trying to make a point?

For the question (If I understand correctly):
1) Most variables don't need to be declared in bash.
2) bash4.2 introduce a new -g to declare a global variable inside a function.

For the point:
Yes the manual says "most" not "all", one interesting hack with aliases is:
http://www.chiark.greenend.org.uk/~sgtatham/aliases.html



reply via email to

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