[GRASS5] SG3d and g.parser

Glynn Clements glynn.clements at virgin.net
Wed Feb 19 18:03:43 EST 2003


John Gillette wrote:

> g.parser appears to be one of those programs not on the CMD/list
> so it wasn't compiled on my system.  When I compile, I get an 
> undefined symbol reference (setenv) in main.o

Sorry, setenv() is a BSD-ism. Try the attached patch.

> Let me ask a few more questions.
> 
> As an example:
> 
> my_script map=f00
> 
> my_script will define all the required parameters for the parser
> in the top portion (as in test.sh) similar to a C program.
> my_script will have on the command line none, some, or all of 
> the required parameters.  The parser will get the command line
> parameters and ask for any missing parameters.  Is this
> correct?

g.parser is a basically just a wrapper around G_parser() etc, so it
should have identical behaviour.

If you run the script with no arguments, G_parser() should use an
interactive question-and-answer session to obtain the values. If you
provide any arguments, then no interaction is performed; if any
required options were omitted, an error message will be printed and
the g.parser will terminate without running the script.

-- 
Glynn Clements <glynn.clements at virgin.net>

-------------- next part --------------
Index: src/general/g.parser/main.c
===================================================================
RCS file: /grassrepository/grass/src/general/g.parser/main.c,v
retrieving revision 1.3
diff -u -r1.3 main.c
--- src/general/g.parser/main.c	15 May 2002 11:38:27 -0000	1.3
+++ src/general/g.parser/main.c	19 Feb 2003 23:00:18 -0000
@@ -283,15 +283,15 @@
     for (flag = ctx.first_flag; flag; flag = flag->next_flag)
     {
 	char buff[12];
-	sprintf(buff, "GIS_FLAG_%c", flag->key);
-	setenv(buff, flag->answer ? "1" : "0", 1);
+	sprintf(buff, "GIS_FLAG_%c=%d", flag->key, flag->answer ? 1 : 0);
+	putenv(G_store(buff));
     }
 
     for (option = ctx.first_option; option; option = option->next_opt)
     {
 	char buff[1024];
-	sprintf(buff, "GIS_OPT_%s", option->key);
-	setenv(buff, option->answer, 1);
+	sprintf(buff, "GIS_OPT_%s=%s", option->key, option->answer);
+	putenv(G_store(buff));
     }
 
     execl(filename, filename, "@ARGS_PARSED@", NULL);


More information about the grass-dev mailing list