Allow interspersing flags and config files

Don't wait for getopt_long to move all the arguments to the end. This
allows overriding options set by config files by placing flags after
them on the command line.
Bu işleme şunda yer alıyor:
C. McEnroe 2021-01-10 13:49:57 -05:00
ebeveyn a437761267
işleme cdff668d8f

Dosyayı Görüntüle

@ -56,21 +56,17 @@ int getopt_config(
const char *optstring, const struct option *longopts, int *longindex
) {
static int opt;
if (opt >= 0) {
opt = getopt_long(argc, argv, optstring, longopts, longindex);
}
if (opt >= 0) return opt;
for (;;) {
if (!file) {
if (optind < argc) {
num = 0;
path = argv[optind++];
file = configOpen(path, "r");
if (!file) return clean('?');
} else {
return clean(-1);
if (optind == argc) return clean(-1);
if (opt >= 0 && argv[optind][0] == '-') {
opt = getopt_long(argc, argv, optstring, longopts, longindex);
if (opt >= 0 || optind == argc) return clean(opt);
}
num = 0;
path = argv[optind++];
file = configOpen(path, "r");
if (!file) return clean('?');
}
for (;;) {