[GRASS5] GRASS scripts and parameter positions

Markus Neteler neteler at geog.uni-hannover.de
Mon Dec 11 12:17:24 EST 2000


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.

Regards

 Markus

---------------------------------------- 
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