浏览代码

g.gisenv: check for mandatory variable which cannot be unset

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64413 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 年之前
父节点
当前提交
f621c4453c
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      general/g.gisenv/main.c

+ 9 - 1
general/g.gisenv/main.c

@@ -9,7 +9,7 @@
  *               Markus Neteler <neteler itc.it>
  *               Markus Neteler <neteler itc.it>
  *               Martin Landa <landa.martin gmail.com>
  *               Martin Landa <landa.martin gmail.com>
  * PURPOSE:      
  * PURPOSE:      
- * COPYRIGHT:    (C) 2003-2014 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2003-2015 by the GRASS Development Team
  *
  *
  *               This program is free software under the GNU General Public
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -165,6 +165,14 @@ int main(int argc, char *argv[])
         n = 0;
         n = 0;
         while (unset_opt->answers[n]) {
         while (unset_opt->answers[n]) {
             u_name = parse_variable(unset_opt->answers[n], &value);
             u_name = parse_variable(unset_opt->answers[n], &value);
+            if (G_strcasecmp(u_name, "GISDBASE") == 0 ||
+                G_strcasecmp(u_name, "LOCATION_NAME") == 0 ||
+                G_strcasecmp(u_name, "MAPSET") == 0) {
+              G_warning(_("Variable <%s> is mandatory. No operation performed."),
+                        u_name);
+              n++;
+              continue;
+            }
             if (value)
             if (value)
                 G_warning(_("Value '%s' ignored when unsetting the GRASS variable"),
                 G_warning(_("Value '%s' ignored when unsetting the GRASS variable"),
                           value);
                           value);