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

Re: aliases versus functions



alex <radsky@ncia.net> writes:

> 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

Why not:

  dist() { mount /mnt/$1; cd /mnt/$1; ls; }
  nodist() { cd; umount /mnt/$1; }

Then you could run 'dist win' and 'nodist win' to get the equivalent
of your aliases above, provided you explain this /mnt/win concept in
/etc/fstab.

> '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.

I'm not sure I can answer the deeper religious question, though.  The
best argument I can come up with is with command-line parameters: if
you typed 'win+ foo' with your alias, the foo would wind up being
passed as a parameter to the ls at the end, but my 'dist win foo'
would result in the foo being ignored.  Also, an 'alias' line might
confuse csh junkies; the function syntax is very similar to
traditional shell script syntax.

(Conventional wisdom, at least in my world, seems to be that you want
to do as little customization in the root account as possible.  If I
were setting up a system like this, I'd probably just mount all of the
relevant partitions all the time; it doesn't really cost anything.)

-- 
David Maze         dmaze@debian.org      http://people.debian.org/~dmaze/
"Theoretical politics is interesting.  Politicking should be illegal."
	-- Abra Mitchell



Reply to: