[GRASS-dev] g.parser and zero length parameter

Hamish hamish_b at yahoo.com
Thu Aug 4 03:32:35 EDT 2011


Maris wrote:
> db.out.ogr script some months a go got a quotes around file
> names to allow spaces in them. That broke db.out.ogr as in one
> case it was calling v.out.ogr and provided an empty parameter:

oops, thanks for noticing/fixing that.


> v.out.ogr "$FOO"
> While $FOO was unquoted, unset $FOO wasn't causing problems,
> still after quoting it, parser started to complain about not
> recognized parameter. It's now hacked around in r47390 [1],

I'm not sure I'd consider it a hack, it is more ensuring correct
usage of command line options in C.


> still I'm wondering if parser shouldn't be changed to ignore
> parameters with 0 length.

I would not change the core parser any more in grass 6.x unless
for a serious bug.
For grass7 I don't know if it is desirable to make g.parser do
special things with argc,argv. But then again, it _is_ a parser,
so letting it make parsing decisions is not so strange..

note many shell scripts add optional flags into an unquoted
variable to allow them to be present or not without triggering
the zero-length argv[] trouble- this is a known issue which has
been worked around like that for years.


> Not backporting fix to 6.4 till consensus on this issue is
> made.

slight variation backported to 6.4 in r47410. please test. 

note that test "-n" is the same as "! -z" for a non-zero length
string.

note the breakage was introduced after 6.4.1, so only present
in development snapshot builds; db.out.ogr works in the last
official release.


Hamish



More information about the grass-dev mailing list