digital adj. Having digits.     peer n. A comrade; a companion; a fellow; an associate. a.k.a. GEEKED    
   
Recent Articles
Mount JFFS2 Image
Saturday, October 25, 2008
Ottawa Linux Symposium 2008
Sunday, July 27, 2008
Here are some pictures from the 2008 Linux Symposium.
Linux Symposium 2008
Sunday, July 20, 2008
I'll be attending the Linux Symposium this year.
Clay Shirky: Institutions vs. collaboration
Monday, July 14, 2008
This is a rather interesting talk that takes some very foundational ideas from open source software development, P2P networks, and social networking and implies that these paradigms can apply to a lot more.
Fremont Street
Sunday, July 29, 2007
Remote Control Dragonfly
Sunday, July 29, 2007
Videos
Sunday, July 29, 2007
Assortment of videos.
Honda CBR F4 Carburetor Cleaning
Monday, July 23, 2007
Details on how to clean F4 carburetors.

Fast, fat computers breed slow, lazy programmers.
- Robert Hummel

Projects-Misc Scripts-Parsing...

Parsing Script Command Line Arguments

Wednesday, January 19, 2005 by digitalpeer

An easy way to parse command line options with or without values in a Bash or variant script file.

for i in $*
do
	case $i in
    	--prefix=*)
		PREFIX=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
		;;
    	--searchpath=*)
		SEARCHPATH=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
		;;
    	--lib=*)
		DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
		;;
    	--default)
		DEFAULT=YES
		;;
    	*)
                # unknown option
		;;
  	esac
done

Comment Thursday, August 28, 2008 by  David C. Rankin, J.D.,P.E.
excellent, with a quick mod you can easily handle both long and short options as well:

-p=*|--prefix=*)

Submit Comment to This Article
Please post a comment if you have something to add, find something wrong, or would like more information on the topic at hand. Do not use the comment form to contact the author about unrelated concerns!

Name: Email (optional):
Enter verification number here: