Closed ghost closed 4 months ago
@rmyorston Can you work on this first? Other issues are hard to debug.
I'm not sure I want to work on this. Detecting (and not ignoring) unknown options seems like the right thing to do.
I'm not sure I want to work on this. Detecting (and not ignoring) unknown options seems like the right thing to do.
Please do anything you think that is right. I only want to be able to proceed with building eepp
.
It seems pdpmake doesn't support GNU style of long options. What about ignoring anything started with --
?
Here's a patch to ignore options starting with --
. It's a non-POSIX extension, so in POSIX mode long options still result in an error. Everything after the first --
isn't treated as an option.
diff --git a/main.c b/main.c
index 0e6e3b7..370587b 100644
--- a/main.c
+++ b/main.c
@@ -463,6 +463,23 @@ main(int argc, char **argv)
} else {
posix = getenv("PDPMAKE_POSIXLY_CORRECT") != NULL;
}
+
+ if (!posix) {
+ int i, j, saw_double_dash = FALSE;
+
+ // As an extension silently ignore options with leading '--'
+ for (i = j = 0; argv[i]; ++i) {
+ if (!saw_double_dash && strncmp(argv[i], "--", 2) == 0) {
+ if (argv[i][2] == '\0')
+ saw_double_dash = TRUE;
+ else
+ continue;
+ }
+ argv[j++] = argv[i];
+ }
+ argv[j] = NULL;
+ argc = j;
+ }
#endif
#if ENABLE_FEATURE_MAKE_POSIX_202X
However, many long options take an argument. So make --jobs 4
becomes make 4
, not at all what was intended.
However, many long options take an argument. So
make --jobs 4
becomesmake 4
, not at all what was intended.
I didn't think about that. What about trying to map long options to the existing options and ignore the ones that currently don't have anything equivalent? This is more involved but is also more flexible, I think.
@rmyorston Please ignore --no-print-directory
as I don't see any existing equivalent option.
I'm not very keen on the idea of adding code to pdpmake
to process GNU make
long options.
Having it reject all long options is just about acceptable, though as we've seen it doesn't work in practice. Having it understand GNU make
long options is a step too far.
Having it reject all long options is just about acceptable, though as we've seen it doesn't work in practice.
However, many long options take an argument. So
make --jobs 4
becomesmake 4
, not at all what was intended.
You can ignore anything after a long option that isn't a short option (doesn't start with a single -
).
rmyorston is right, it does not make sense to ignore unsupported flags. there are reasons why you dont see serious applications doing that (e.g busybox). imagine someone passing a long option, expecting GNU behaviour then pulling their hair out, unable to find what is wrong with their command because clearly pdpmake "accepted" it; or alternatively breaking scripts without warning; etc...
You can ignore anything after a long option that isn't a short option
No, that won't work. There are cases where a long option can take an argument starting with a single dash: make --file -Makefile
or make --eval '-include file'
.
(I didn't say they were sensible cases ;-)
@rmyorston
Just an idea of a possible way:
Add a small list of commonly used long options with one parameter, like as it was done inside mixed_case_special_name:
const char *names = "PATH=\0""COMSPEC=\0""PROGRAMDATA=\0";
For the ones inside the list ignore them with the parameter instead for all others ignore them without parameters.
But the most improtant thing is to emit a warning for every ignored parameter.
For example,
--no-print-directory
. Currently, it will abort with this error: