[postgis-tickets] r14993 - Added end-of-options flag '--' to shp2pgsql-cli arguments parser

Sandro Santilli strk at kbt.io
Fri Jul 8 09:37:58 PDT 2016


Author: strk
Date: 2016-07-08 09:37:58 -0700 (Fri, 08 Jul 2016)
New Revision: 14993

Modified:
   trunk/loader/shp2pgsql-cli.c
Log:
Added end-of-options flag '--' to shp2pgsql-cli arguments parser

Patch by J?\195?\182rg Habenicht <jh at mwerk.net>

Modified: trunk/loader/shp2pgsql-cli.c
===================================================================
--- trunk/loader/shp2pgsql-cli.c	2016-07-05 10:51:10 UTC (rev 14992)
+++ trunk/loader/shp2pgsql-cli.c	2016-07-08 16:37:58 UTC (rev 14993)
@@ -64,6 +64,7 @@
 	printf(_( "  -X <tablespace> Specify the tablespace for the table's indexes.\n"
                   "      This applies to the primary key, and the spatial index if\n"
                   "      the -I flag is used.\n" ));
+	printf(_( "  --  End of options. Use this for unusual file names starting with '-' \n" ));
 	printf(_( "  -?  Display this help screen.\n" ));
 }
 
@@ -95,8 +96,12 @@
 	set_loader_config_defaults(config);
 
 	/* Keep the flag list alphabetic so it's easy to see what's left. */
-	while ((c = pgis_getopt(argc, argv, "acdeg:ikm:nps:t:wDGIN:ST:W:X:")) != EOF)
+	while ((c = pgis_getopt(argc, argv, "-acdeg:ikm:nps:t:wDGIN:ST:W:X:")) != EOF)
 	{
+		// can not do this inside the switch case
+		if ('-' == c)
+			break;
+
 		switch (c)
 		{
 		case 'c':



More information about the postgis-tickets mailing list