Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permute non-option arguments after -- #5

Open
wangp opened this issue Jun 9, 2019 · 0 comments
Open

Permute non-option arguments after -- #5

wangp opened this issue Jun 9, 2019 · 0 comments

Comments

@wangp
Copy link
Contributor

wangp commented Jun 9, 2019

For GNU compatibility, ya_getopt may want to permute non-option arguments to after "--", e.g.

$ ./test1.ya foo bar -- -x -y
foo bar -- -x -y

vs.

$ ./test1.gnu foo bar -- -x -y
-- foo bar -x -y

Here is the test program:

#include <stdio.h>
#ifdef YA
#include "../ya_getopt.h"
#else
#include <getopt.h>
#endif

int main(int argc, char **argv)
{
    char *optstring = "ab:";
    int opt;
    int i;

    while ((opt = getopt(argc, argv, optstring)) != -1) {
    }
    for (i = 1; i < argc; i++) {
        printf("%s ", argv[i]);
    }
    printf("\n");
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant