Bourne shell: send arguments $2 to $N to variadic function?

Viewed 5334

Google has finally failed me. I cannot seem to find how to do this in Bourne shell scripting:

I am writing a shell script to handle all of my testing for a project. I've set up functions for each task that this script could do (build, run, clean, etc), and would like to pass any additional command-line parameters (besides the command itself) onto the desired function.

Example:

./test.sh build -j should pass -j into the build function.

A pseudo-code version of this logic would look like:

function build() {
   make $*
}

if [ $1 == 'build' ]; then
   build $2 -> $N
fi

How can I accomplish this?

3 Answers
Related