Quote:
But doesn't zsh have all that cool autoloading stuff you can use for defining functions?
|
Indeed, but that's mainly intended for interactive use, rather than in scripts (though I suppose you can use it in a script as long as you run compinit etc).
Quote:
however sourcing it executes it and things get all messy from there.
|
If you're sourcing files, it's usually better to put everything in functions, so the code is only executed when the function is called.
Could you reverse the logic? E.g.
Code:
if [[ ${0:t} == makepkg ]]; then
... do whatever
else
... do something else
fi
Any good?
Note that you don't need to quote $variables in zsh (unless you set shwordsplit). Also, :t does the same job as basename without spawning another program.