-
Notifications
You must be signed in to change notification settings - Fork 44
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
[FR] Add -- option to prevent interpretation of filenames with dashes #59
Comments
Quick and dirty patch: diff --git a/dragon.c b/dragon.c
index 2e1e635..4d1e4e7 100644
--- a/dragon.c
+++ b/dragon.c
@@ -516,6 +516,8 @@ int main (int argc, char **argv) {
exit(1);
}
argv[i][0] = '\0';
+ } else if (strcmp(argv[i], "--") == 0) { /* "--" stops option processing */
+ break;
} else if (argv[i][0] == '-') {
fprintf(stderr, "%s: error: unknown option `%s'.\n",
progname, argv[i]);
@@ -566,8 +568,10 @@ int main (int argc, char **argv) {
else if (drag_all)
uri_collection = malloc(sizeof(char*) * ((argc > MAX_SIZE ? argc : MAX_SIZE) + 1));
- for (int i=1; i<argc; i++) {
- if (argv[i][0] != '-' && argv[i][0] != '\0')
+ for (int optended = 0, i=1; i<argc; i++) {
+ if (strcmp(argv[i], "--") == 0)
+ optended = 1;
+ else if (optended || (argv[i][0] != '-' && argv[i][0] != '\0'))
make_btn(argv[i]);
}
if (from_stdin) |
Thanks @N-R-K! That seems to work perfectly! |
N-R-K
added a commit
to N-R-K/dragon
that referenced
this issue
Dec 1, 2022
since it's valid for filenames to begin with a dash, there's an ambiguity on weather something like `-i` refers to the cli flag or a file named `-i`. the convention is to use a double-dash "--" as a way to mark the end of cli options so that everything that comes after it can be treated as arguments. Closes: mwh#59
krayon
pushed a commit
to krayon/dragon-drag-drop-tool
that referenced
this issue
Aug 3, 2024
since it's valid for filenames to begin with a dash, there's an ambiguity on weather something like `-i` refers to the cli flag or a file named `-i`. the convention is to use a double-dash "--" as a way to mark the end of cli options so that everything that comes after it can be treated as arguments. Closes: mwh#59
krayon
pushed a commit
to krayon/dragon-drag-drop-tool
that referenced
this issue
Aug 3, 2024
since it's valid for filenames to begin with a dash, there's an ambiguity on weather something like `-i` refers to the cli flag or a file named `-i`. the convention is to use a double-dash "--" as a way to mark the end of cli options so that everything that comes after it can be treated as arguments. Closes: mwh#59
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Observed behaviour
The dragon window only show files
a
andb
, using-i
as the option (i.e.--icon-only
).Expected behaviour
dragon should interpret
-i
correctly as a file, not as an option. This could be by a--
option, i.e.The text was updated successfully, but these errors were encountered: