Speaking of redirections... Here's another fut bit of lesser-known shell: f(){ cat;} I.e. You can bind redirections to function definitions that end up applying at call time.
what is a use of that vs f () { cat file; } Why make the shell open and read the file and pipe in to the cat process when cat would open and read the file itself directly? I guess the point is not cat but the redirection itself. ie, if the contents of f() were not simply cat, and maybe there was no handy place to put the filename within. Though, I think I still struggle to think up an example even then.
log(){
foo "$1"
bar "$2"
} >>logfile
Redirecting stdin is a little more subtle: contents(){
maybeReadStdinA
maybeReadStdinB
}
where the first command to read stdin gets the contents of input and subsequent commands see nothing.