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

Re: multi-alias syntax



On Jun 25,  1:08am, Emanuel Berg wrote:
}
}     debian-version debian-ver version ver () { lsb_release -a } # 1
}     # 2
}     debian-version () { lsb_release -a }
}     alias {debian-ver,version,ver}=debian-version

Or #3

    alias {debian-,}{version,ver}='lsb_release -a'

} Anyone cares to line up the pros and cons of the two
} approaches? - in terms of programming, and use.
}  
} I can already tell they are not identical as in (1)
} debian-ver etc. are functions, not aliases.

That's the only difference that really matters.

General differences/gotchas with using aliases is covered in FAQ
question 2.3 ( http://zsh.sourceforge.net/FAQ/zshfaq02.html#l12 ).

Specific to this example:

#1 - uses slightly more memory
   - after the functions are defined, they are separate objects, so
     changing one of them doesn't change the others

#2 - changing the function changes (the outcome of) all the aliases
   - changing any of the aliases doesn't change the others

#3 - changing any of the aliases doesn't change the others

Of course if you're never going to change anything on the fly once
it has been defined in your startup, most of that is irrelevant.

The additional point is that aliases expand at parse time, so if you
define an alias, then load a function that refers to the alias, and
later redefine the alias, the function will continue executing the
original expansion of the alias.

Given that you said:

} I want long and descriptive name in the
} source so I can understand it years later. But for
} interactive use I want short names in many versions.

I'd probably go with #2.



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