[GRASS-SVN] r56197 - grass/trunk/db/db.connect

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 11 06:00:04 PDT 2013


Author: martinl
Date: 2013-05-11 06:00:03 -0700 (Sat, 11 May 2013)
New Revision: 56197

Modified:
   grass/trunk/db/db.connect/main.c
Log:
db.connect: cosmetics (print flags)


Modified: grass/trunk/db/db.connect/main.c
===================================================================
--- grass/trunk/db/db.connect/main.c	2013-05-11 12:49:53 UTC (rev 56196)
+++ grass/trunk/db/db.connect/main.c	2013-05-11 13:00:03 UTC (rev 56197)
@@ -111,42 +111,35 @@
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    if (shell->answer) {
+    if (print->answer || shell->answer) {
 	/* get and print connection in shell style */
 	if (db_get_connection(&conn) == DB_OK) {
-	    fprintf(stdout, "driver=%s\n",
-		    conn.driverName ? conn.driverName : "");
-	    fprintf(stdout, "database=%s\n",
-		    conn.databaseName ? conn.databaseName : "");
-	    fprintf(stdout, "schema=%s\n",
-		    conn.schemaName ? conn.schemaName : "");
-	    fprintf(stdout, "group=%s\n", conn.group ? conn.group : "");
-	}
+            if (shell->answer) {
+                fprintf(stdout, "driver=%s\n",
+                        conn.driverName ? conn.driverName : "");
+                fprintf(stdout, "database=%s\n",
+                        conn.databaseName ? conn.databaseName : "");
+                fprintf(stdout, "schema=%s\n",
+                        conn.schemaName ? conn.schemaName : "");
+                fprintf(stdout, "group=%s\n", conn.group ? conn.group : "");
+            }
+            else {
+                fprintf(stdout, "driver: %s\n",
+                        conn.driverName ? conn.driverName : "");
+                fprintf(stdout, "database: %s\n",
+                        conn.databaseName ? conn.databaseName : "");
+                fprintf(stdout, "schema: %s\n",
+                        conn.schemaName ? conn.schemaName : "");
+                fprintf(stdout, "group: %s\n", conn.group ? conn.group : "");
+            }
+        }
 	else
 	    G_fatal_error(_("Database connection not defined. "
 			    "Run db.connect."));
-
+        
 	exit(EXIT_SUCCESS);
     }
-
-    if (print->answer) {
-	/* get and print connection */
-	if (db_get_connection(&conn) == DB_OK) {
-	    fprintf(stdout, "driver: %s\n",
-		    conn.driverName ? conn.driverName : "");
-	    fprintf(stdout, "database: %s\n",
-		    conn.databaseName ? conn.databaseName : "");
-	    fprintf(stdout, "schema: %s\n",
-		    conn.schemaName ? conn.schemaName : "");
-	    fprintf(stdout, "group: %s\n", conn.group ? conn.group : "");
-	}
-	else
-	    G_fatal_error(_("Database connection not defined. "
-			    "Run db.connect."));
-
-	exit(EXIT_SUCCESS);
-    }
-
+    
     if (check_set_default->answer) {
 	/* check connection and set to system-wide default in required */
 	/*



More information about the grass-commit mailing list