bash functions example

Bradley Taylor (of [Railsmachine](http://railsmachine.com/) hosting fame) said this on [the excellent Mongrel mailing list](http://rubyforge.org/mailman/listinfo/mongrel-users):

“Just use these bash functions and put them in your .bashrc:”

  cluster\_restart () { 
	mongrel\_rails cluster::restart -C /etc/ mongrel\_cluster/$1.yml;
  }
  cluster\_start () {
	mongrel\_rails cluster::start -C /etc/ mongrel\_cluster/$1.yml;
  }
  cluster\_stop () {
	mongrel\_rails cluster::stop -C /etc/mongrel\_cluster/$1.yml;
  }

  usage:
  $ cluster_start fluxura


([See the thread in the archives](http://rubyforge.org/pipermail/mongrel-users/2006-July/000780.html).)

That is, when someone asked about if it wasn’t possible to just have a command, and that it’d be cool if Mongrel had such a simple command, he shows code.

Also, the example’s great.

* The $1 to access the first argument to the function call, and that
* you don’t need to put in any parameter lists in the functions, and that
* its control structures looks mostly like any C-like language.

I feel kickstarted by this. Thanks, Bradley.

[tags]bash,unix[/tags]

Published by Olle Jonsson

Human. Wears glasses and often a smile.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.