Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#537596: regression: parse error near `()' in function definition



2009/7/20 Peter Stephenson <pws@xxxxxxx>:
> On Sun, 19 Jul 2009 23:20:41 +0000
> Clint Adams <schizo@xxxxxxxxxx> wrote:
>> On Sun, Jul 19, 2009 at 07:16:51PM +0200, martin f krafft wrote:
>> > % eval 'lt() { (_lt-en $*; _en-lt $*) | more }'
>> > zsh: parse error near `()'
>> >
>> > Alright, so lt is special:
>> >
>> > % which lt
>> > lt: aliased to ls -lt
>
> Assuming lt was defined as an alias first, this has always been the wrong
> thing to do:
>
> % alias lt="one two"
> % eval 'lt() { (_lt-en $*; _en-lt $*) | more }'
> % which one two
> one () {
>        (
>                _lt-en $*
>                _en-lt $*
>        ) | more
> }
> two () {
>        (
>                _lt-en $*
>                _en-lt $*
>        ) | more
> }
>
> This is not a new feature; it's been mentioned in the FAQ for many years.

Just thought I'd mention you can also use \ at any time to escape an alias:

% alias lt="one two"
% eval '\lt() { echo foo }'
% which lt
lt: aliased to one two
% unalias lt
% which lt
lt () {
	echo foo
}
% alias lt="one two"
% which lt
lt: aliased to one two
% lt
zsh: command not found: one
% \lt
foo
% l\t
foo

-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author