aliases versus functions
I've been using a collection of aliases for a few years and I've
been told many times that I should be using 'functions ' to do the
same job that my aliases do quite well. I'm told that aliases are
not suited for running compound commands but should be limited to
simple equivalents such as
alias cd..='cd ..'. or alias ls='ls -aF --color=auto'
For example, I use an alias ' win+ ' to get into my Windows 98SE
from Debian----
alias win+='mount -t vfat /dev/hda1 /mnt/da1; cd /mnt/da1;
ls'
alias win-='cd; umount /mnt/da1' (to unmount)
(I created da1/ in /mnt/
I have multiple Linux distributions installed and can access any of
them from another with aliases constructed along the lines of the
above example. I keep them in /root/.bashrc
Just a few minutes ago, I had need of a file which wasn't in knoppix
/dev/ but was available in Lycoris /dev/. Alias came to the
rescue. I was in knoppix so I typed ' lyco+ ' and copied the file
from Lycoris /dev/ to knoppix /dev/ where it works perfectly..
'Functions' just take up too much space----aliases of compound
commands are much more compact and as far as I can tell work as well
as 'Functions'. So, why is everyone so set against using aliases
for compound commands? It's like telling bees not to fly because
they're aerodynamically unsuited for flight.
alex
Reply to: