Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 May 1997 07:09:50 -0800 (AKDT)
From:      Steve Howe <un_x@anchorage.net>
To:        freebsd-questions <questions@freebsd.org>
Subject:   getopts
Message-ID:  <Pine.BSF.3.95q.970510065341.11982A-100000@aak.anchorage.net>

next in thread | raw e-mail | index | archive | help

after pondering what use "getopts" was over "manual" parsing,
i finally realized "getopts" can deal with option globbing, ie,
i can pass "script -abc" to
 
while getopts abc i; do

	case $i in
			a) blah, blah
			b) blah, blah
			c) blah, blah
	esac
done

my questions is: how can i set the positional parameters to
$1=a, $2=b, $3=c, etc.  is this replacement for getopt(1)
supposed to get rid of the idea of positional parameters?

i can do		a) a=$i
			b) b=$i
			c) c=$i

but this seems tedious, and i still don't have "shiftable" variables ...
i tried various versions of "set -- `getopts abc i` $*", etc.
but i can only end up with "$1 = -abc" ... 
-------------------------------------------------------------------------
 Sleep: a sign a caffeine deprivation ... http://www.anchorage.net/~un_x
-------------------------------------------------------------------------




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.95q.970510065341.11982A-100000>