[GRASS-dev] [GRASS GIS] #2579: Specify command to be exectued as parameter of grass command

GRASS GIS trac at osgeo.org
Wed Feb 11 15:03:42 PST 2015


#2579: Specify command to be exectued as parameter of grass command
----------------------------------------------+-----------------------------
 Reporter:  wenzeslaus                        |       Owner:  grass-dev@…              
     Type:  enhancement                       |      Status:  new                      
 Priority:  normal                            |   Milestone:  7.1.0                    
Component:  Startup                           |     Version:  svn-trunk                
 Keywords:  batch job, GRASS_BATCH_JOB, init  |    Platform:  All                      
      Cpu:  Unspecified                       |  
----------------------------------------------+-----------------------------

Comment(by wenzeslaus):

 Replying to [comment:1 mlennert]:
 > Why do you need the --mapset as in:
 >
 {{{
 grass7 --mapset ~/grassdata/location/mapset --batch r.mapcalc "aaa = 5"
 }}}
 >
 > ?
 >
 > The current GRASS startupt script already allows to define a mapset at
 startup, so this seems redundant.
 >

 This is a thing I'm not sure about. The current syntax is

 {{{
 grass ~/grassdata/nc_spm_08_grass7/user1
 grass -c ~/grassdata/nc_spm_08_grass7/user1
 }}}

 which follows the following general pattern

 {{{
 name options/flags files
 name [option]... [file]...
 name [option]... [file] [arg]...
 }}}

 where options/flags are distinguished by `-` or `--` and first thing which
 is not an option starts a file list. The last row actually describes
 `python` and `Rscript`:

 {{{
 python [option] ... [-c cmd | -m mod | file | -] [arg] ...
 Rscript [--options] [-e expr [-e expr2 ...] | file] [args]
 }}}

 So it seems that they actually leave out (equivalent of) `--batch`. If we
 would allow not to specify db+l+mapset then one could use:

 {{{
 grass .../test_script.sh
 grass r.info
 grass r.mapcalc "aaa = 5"
 }}}

 which could be hard to distinguish from (current):

 {{{
 grass ~/grassdata/nc_spm_08_grass7/user1
 }}}

 We can also say that db+l+mapset is always required when passing module or
 script because the usual use case is when GRASS GIS is used as processing
 backend and in this case you rarely want to use db+l+mapset from rc file.
 This gives us:

 {{{
 grass ~/grassdata/nc_spm_08_grass7/user1 .../test_script.sh
 grass ~/grassdata/nc_spm_08_grass7/user1 r.info
 grass ~/grassdata/nc_spm_08_grass7/user1 r.mapcalc "aaa = 5"
 }}}

 In this case, I'm not sure how well we can distinguish different cases
 (standard/batch) when parsing and how we can provide good error messages.

 Similar, but not the same, case is `grep`. With `grep` you always have to
 provide the `PATTERN` parameter:

 {{{
 grep [OPTION]... PATTERN [FILE]...
 }}}

 In our case all parameters would be optional. The order is really
 important in this case and identification of options can become tricky,
 although hopefully not as much as with `grep` (try to search for a string
 which starts with `-`). If we decide for something like this, the command
 line parsing in `grass.py` will have to be reimplemented, at least I think
 according to the code. For example, you have to recognize where the actual
 command starts because then everything else should not be used (trivial
 with `--batch`, hard without).

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/2579#comment:2>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list