#!/bin/sh # call with --basedir=x --datadir=y --pid-file=z parse_arguments() { for arg do case "$arg" in --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; --pid-file=*) pid_file=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; esac done } # $@ is all the arguments; shell will expand parse_arguments $@ echo $basedir echo $datadir echo $pid_file