Monday, November 14, 2011

Bash Development Tools

We introduce our organization of custom bash scripts for development.

Script Types

Bash is essential for automating tasks in Ubuntu. Generally, you'll work with three kinds of bash scripts:

  • Distribution scripts—these come with your Linux distribution
  • Deployed scripts—these come with deb packages that you install
  • Personal scripts—these are fully under your control and live in your home folder

You'll need a folder where you store your personal bash scripts. As with any code, this should be placed under source control.

Please see our short guide on source control and ensure your environment is set up appropriately.

Personal Bash Repository

In the interest of consistency, let's choose mysh as the project name for personal scripts. Create your project on your BitBucket account. Then check out your new project into

$HOME/hgdev/org.bitbucket/${user}/mysh

Now modify your $HOME/.bashrc to include this folder on your PATH

export PATH=$HOME/hgdev/org.bitbucket/${user}/mysh:$PATH

You'll need to reload your .bashrc for this to take effect. You can just open a new terminal.

Let's create a sample program hello.sh to test our configuration.

#!/usr/bin/env bash
echo "hello"

This should be in your mysh folder. Make this script executable

chmod +x hello.sh

Let's change folders to our home.

cd
hello.sh

This should execute your program.

Eclipse Setup for Bash

ShellEd is a good plugin for Eclipse for editing bash scripts. However it can be tricky to install. We assume Eclipse Indigo Service release 1.

Prerequisites

ShellEd requires Linux Man Tools.

Add Update Site

Go to Help -> Install New Software... ->

Linux Tools
http://download.eclipse.org/technology/linuxtools/update

Install the Linux Man Tools. Then install ShellEd

ShellEd
https://downloads.sourceforge.net/project/shelled/shelled/ShellEd%202.0.1/update


No comments: