[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Functions or aliases?

I've been using the following to access MS Win 98 from

alias win+='mount -t vfat /dev/hda1 /mnt/hda1; cd /mnt/hda1; ls -aF --color=auto' (This is located in /root/.bashrc)

By simply typing 'win+' all of Win98 becomes accessible for copying, moving, or editing in either direction. I've even made a complete 4 GB backup of Win98 after executing 'win+' with this alias:

alias bup='cp -afv /mnt/hda1/* /mnt/hdb1/ '

(alias win-='cd; umount /mnt/hda1'  is used to unmount)

I've read that aliases should be limited to simpler
commands such as:
     alias cd..='cd ..'  or  alias lsl='ls -l'
and that aliases like my win+ should be structered as a function instead of an alias. I've tried the same command in function form and I don't see any difference.

So what's the reason why compound commands should be in function form? I suspect that it might be because long commands tend to become word wrapped, they may not work but in function form, each line is short enough so word wrap doesn't occur. I had difficulty with some longer aliases until I discovered that word wrap has to be turned off.

Is there some other reason to use functions instead of aliases for complex commands?

Reply to: