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

Re: Functions or aliases?



I use the simple rule:

 - aliases take no arguments (or take arguments in a trivial way e.g.
   "alias ls='ls --color-auto')
 - functions take arguments

So, I'd stick to using an alias in the case you describe.

/M

On Sat, May 08, 2004 at 10:00:38PM -0400, alex wrote:
>I've been using the following to access MS Win 98 from
>Debian.
>
>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?
>
>
>
>
>
>
>
>-- 
>To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
>with a subject of "unsubscribe". Trouble? Contact 
>listmaster@lists.debian.org
>

-- 
Magnus Therning                    (OpenPGP: 0xAB4DFBA4)
magnus@therning.org
http://magnus.therning.org/

The second oldest profession is book keeping.
     -- Craig Burton

Attachment: signature.asc
Description: Digital signature


Reply to: