[GRASS-dev] New wiki page summarising GRASS APIs

Moritz Lennert mlennert at club.worldonline.be
Tue Feb 3 10:04:13 PST 2015


On 03/02/15 16:35, Glynn Clements wrote:
>
> Moritz Lennert wrote:
>
>> This is what the warning before the system call examples says:
>>
>> "Warning: In many cases, system calls such as these demand that you
>> really know what you are doing. If you want to program in Python, you
>> are encouraged to rather use the existing Python APIs explained below
>> instead of such system calls."
>>
>> And then it goes on with:
>>
>> "These system calls are easy to handle when no output is expected from
>> the GRASS module. When output needs to be collected then the programming
>> task already becomes a little harder unless you know what you are doing.
>> Equally, they can be tricky when introducing variable arguments and
>> special characters. It is for this reason that the Python GRASS
>> libraries where developed that are explained in the next section."
>>
>> I hope this is explicit enough.
>
> I still think that the C version should either be removed or use e.g.
> posix_spawn() or G_spawn*() instead of system() (note: the Windows
> spawn*() functions aren't safe; they merely concatenate their
> arguments with spaces inbetween, which is no better than system()).
>
> The perl version should be changed to use the list form of system()
> rather than the string form, e.g.
>
> 	@args = ("r.watershed", "elevation=elevation", "threshold=10000", "stream=raster_streams");
> 	system(@args);
>
> Under no circumstances should a command be passed as a string, even in
> examples. Especially in examples. Telling people not to use that
> approach won't work, particularly when it's the only approach
> demonstrated.
>

Ok, I've removed the C example and replaced the perl example with your 
version.

Thanks !

Moritz


More information about the grass-dev mailing list