[Box Backup-commit] COMMIT r1720 - box/chris/merge/lib/server

boxbackup-dev@fluffy.co.uk boxbackup-dev@fluffy.co.uk
Tue, 03 Jul 2007 22:13:57 +0100


Author: chris
Date: 2007-07-03 22:13:56 +0100 (Tue, 03 Jul 2007)
New Revision: 1720

Modified:
   box/chris/merge/lib/server/Daemon.cpp
Log:
Hopefully work around buggy getopt implementation noted by TBP in
http://lists.warhead.org.uk/pipermail/boxbackup/2007-July/003614.html
(refs #3)


Modified: box/chris/merge/lib/server/Daemon.cpp
===================================================================
--- box/chris/merge/lib/server/Daemon.cpp	2007-07-01 22:55:51 UTC (rev 1719)
+++ box/chris/merge/lib/server/Daemon.cpp	2007-07-03 21:13:56 UTC (rev 1720)
@@ -124,12 +124,21 @@
 
 	while((c = getopt(argc, (char * const *)argv, "c:DFqvVt:Tk")) != -1)
 	{
-		BOX_TRACE("getopt: returned '" << c << "'");
+		BOX_TRACE("getopt: returned '" << c << "' (" << (int)c << ")");
 		BOX_TRACE("getopt: optind = " << optind);
 		BOX_TRACE("getopt: optopt = " << optopt);
 		BOX_TRACE("getopt: optarg = " << optarg);
 		BOX_TRACE("getopt: argv[optind] = " << argv[optind]);
 
+		// Workaround for weird behaviour noted by TBP in
+		// http://lists.warhead.org.uk/pipermail/boxbackup/2007-July/003614.html
+		if (c == '?' && optopt == 0)
+		{
+			// this apparently means "end of options" in some
+			// buggy libc?
+			break;
+		}
+
 		switch(c)
 		{
 			case 'c':