@@ -322,10 +322,19 @@ class cmdline_processor
322
322
if (arg.text .empty ()) {
323
323
continue ;
324
324
}
325
+
326
+ // Provide a way to ignore the rest of the command line
327
+ // for the purpose of looking for switches
328
+ if (arg.text == " --" ) {
329
+ arg.pos = processed;
330
+ break ;
331
+ }
332
+
325
333
for (auto & flag : flags) {
334
+ auto length_to_match = std::max (flag.unique_prefix , as<int >(arg.text .length ())-1 );
326
335
// Allow a switch to start with either - or /
327
- if (arg.text .starts_with (" -" + flag.name .substr (0 , flag. unique_prefix )) ||
328
- arg.text .starts_with (" /" + flag.name .substr (0 , flag. unique_prefix )) ||
336
+ if (arg.text .starts_with (" -" + flag.name .substr (0 , length_to_match )) ||
337
+ arg.text .starts_with (" /" + flag.name .substr (0 , length_to_match )) ||
329
338
arg.text == " -" + flag.synonym ||
330
339
arg.text == " /" + flag.synonym
331
340
)
@@ -335,11 +344,15 @@ class cmdline_processor
335
344
break ;
336
345
}
337
346
}
338
- if (arg.pos != processed && (arg.text .starts_with (" -" ) || arg.text .starts_with (" /" ))) {
339
- arg.pos = processed;
340
- print (" Unknown option: " + arg.text + " (try -help)\n " );
341
- help_requested = true ;
342
- }
347
+
348
+ // For now comment this out to try leaving unmatched switches alone, so that
349
+ // Unix absolute filenames work... and in case an absolute filename collides
350
+ // with a legit switch name, also added "--" above... let's see how this works
351
+ // if (arg.pos != processed && (arg.text.starts_with("-") || arg.text.starts_with("/"))) {
352
+ // arg.pos = processed;
353
+ // print("Unknown option: " + arg.text + " (try -help)\n");
354
+ // help_requested = true;
355
+ // }
343
356
}
344
357
345
358
std::erase_if ( args, [=](auto & arg){ return arg.pos == processed; } );
0 commit comments