[GRASS5] g.manual and getopts

From: Markus Neteler <neteler@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 :slight_smile:
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 :slight_smile:

Yours,
Huidae Cho

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'

On Tue, Dec 12, 2000 at 12:24:22PM +0900, GRASS wrote:

From: Markus Neteler <neteler@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 :slight_smile:
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 :slight_smile:

We need someone who reads/write tcl: In
src/tcltkgrass/main/gui.tcl

the order of parameters is defined (where the command line is build).
Unfortunately I have no idea where to find that within this file.
Maybe a simple change in order would achive that tcltkgrass writes
in it's command line:
<module> <flag(s)> <parameter>

Hope we find a tcl/tk professional to change that,

Markus

----------------------------------------
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo@geog.uni-hannover.de with
subject 'unsubscribe grass5'