Thanks, Strike - so basically, I should look at aliases like a fancy form of tab-completion - they don't have anything to do with scripting at all, and I can just set them aside? If it's something I just want while I'm typing on the command line, an alias is fine, but they aren't good for anything else and, if I want it in other contexts, I need it to take some other form? I mean, aliases can perform some reasonably full actions - like
Code:
alias bakmarks='cp /home/...gibberish.../bookmarks.html ~/html'
but they can't do 'cp $1 $2' so they're only good for a specific objective. (And I guess the shell does tilde expansion within aliases, but not variable expansion? The issue isn't expansion as such, but what kind of expansion.)
So that leaves functions and outright scripts. Thanks to you, too, jim. By 'login script', did you mean ~/.bash_profile or ~/.bash_login - or something special to be sourced? But I do have some functions in ~/.bash_profile. However, they're not necessarily anything I reuse in scripts - more like things that just stretched the capacity of aliases. But you're saying that functions are primarily intended to be reusable code segments and not a way to cheat around the limits of aliases? So if I have something I don't intend to reuse I *can* put them in my environment but that either isn't the real purpose or is something for private scripts, only. If I was doing serious scripting, they'd need to be portable, so should reference functions contained in the scripts thmeselves?
For instance, sometimes I want to know what package something came out of so
Code:
whose ()
{
grep -iR $1 /var/log/packages | less -e
}
does that for me. An alias wouldn't cut it, because it has to be variable but it's not worth an independent script and isn't anything I reuse in any other scripts. So that's appropriate?
And basically, if it's for my personal use, it's just a matter of degree? If it's more than a simple line I can throw in ~/.bash_profile, it might as well be a script? (I mean, obviously if I'm trying to write a non-trivial script it's not a case of 'might as well be' but I mean for the borderline silly stuff.)
I want to make sure I'm not missing any gotchas, either. You lose aliases in subshells and lose environment functions in other environments but a well-written, self-contained (as much as scripts can be), compatible /bin/sh script will run most anywhere and so on. And the functions contained within it are the same way, naturally, as long as they are contained within it.
Right? Maybe?