Skip to content

Commit

Permalink
qfile-agent: Support -- for end of options
Browse files Browse the repository at this point in the history
This is how command line utilities should work.
  • Loading branch information
DemiMarie committed May 15, 2024
1 parent d95e0e2 commit 12f103a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions qubes-rpc/qfile-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdbool.h>
#include <gui-fatal.h>
#include <libqubes-rpc-filecopy.h>

Expand Down Expand Up @@ -81,10 +82,17 @@ int main(int argc, char **argv)
invocation_cwd_fd = open(".", O_PATH | O_DIRECTORY);
if (invocation_cwd_fd < 0)
gui_fatal("open \".\"");
bool ignore_options = false;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "--ignore-symlinks")==0) {
ignore_symlinks = 1;
continue;
if (!ignore_options) {
if (strcmp(argv[i], "--ignore-symlinks")==0) {
ignore_symlinks = 1;
continue;
}
if (strcmp(argv[i], "--") == 0) {
ignore_options = true;
continue;
}
}
if (!*argv[i])
gui_fatal("Invalid empty argument %i", i);
Expand Down

0 comments on commit 12f103a

Please sign in to comment.