[GRASS5] g.manual and getopts
GRASS
grass at geni.knu.ac.kr
Mon Dec 11 22:24:22 EST 2000
From: Markus Neteler <neteler at geog.uni-hannover.de>
>
> Hi all,
>
> just found (probably) a solution for the problem of parameter/flag
> positioning in GRASS scripts (especially tcltkgrass is affected, reported by
> Andreas for g.manual):
>
> getopts
> http://orca.st.usm.edu/~seyfarth/unix/unix-6-11-17.html
>
> * getopts gets shell scripts options
>
> * while getopts ivo: op
> do
> case $op in
> i) invert=1 ;;
> v) verbose=1 ;;
> o) filename=$OPTARG ;;
> esac
> done
> shift 'expr $OPTIND - 1'
>
> * After the shift the remaining arguments are in $*
>
> * Script option syntax is flexible:
> doit -i -v file1
> doit -iv file1 -o file2
>
>
> This might be a way to allow flexible flag/parameters:
> man getopts:
> "getopts is used by shell procedures to parse positional parameters."
>
> Maybe someone is willing to update g.manual script and we update other
> scripts later while learning from the g.manual implementation.
>
Hi developers,
Actually it's another problem. getopts can not understand command line like
the following:
doit this that -i -v file1 # BAD USAGE
getopts assumes that ALL options(like -?) are followed by another arguments.
doit -i -v file1 this that # GOOD USAGE
And tcltkgrass may want bad usage :-)
I think the latter is more standard. isn't it?
Anyway, I changed g.manual to use getopts. This can not work with current
tcltkgrass.
"g.manual entries=d.area -f" should be changed to "g.manual -f entries=d.area".
In addition, -f flag is not implemented by original g.manual script author
and i don't know what it is.
Now, g.manual allows some flexibility. However, each option in g.manual is
exclusive to another. So this may be useless :-)
Yours,
Huidae Cho
----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'
More information about the grass-dev
mailing list