From a05ceb98259b949dcc248c744c809df3a7d06233 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Sat, 12 Jun 2021 19:50:33 +0000 Subject: lpass: call the function of command without argv[0] --- src/exec-cmd.c | 11 ++--------- src/lpass.c | 4 ++-- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/exec-cmd.c b/src/exec-cmd.c index 0751d29..6955a20 100644 --- a/src/exec-cmd.c +++ b/src/exec-cmd.c @@ -77,9 +77,6 @@ int cmd_insert(int argc, char *argv[]) } } - if(optind < argc) optind++; // for skip "insert" - dbgprint("passname: %s\n", argv[optind]); - char *path = argv[optind]; if(path == NULL) usageprint("%s", description); @@ -158,7 +155,7 @@ int cmd_edit(int argc, char *argv[]) /* We expect tmpfs to be mounted at /dev/shm */ char path_tmpfile[] = "/dev/shm/lpass.XXXXXX"; char *editor, *password; - char *path = argv[2]; + char *path = argv[1]; if(!path) usageprint("%s", description); @@ -262,9 +259,6 @@ int cmd_generate(int argc, char *argv[]) } } - if(optind < argc) optind++; // for skip "generate" - dbgprint("passname: %s\n", argv[optind]); - char *path = argv[optind]; if(path == NULL) usageprint("%s", description); @@ -308,7 +302,7 @@ int cmd_remove(int argc, char *argv[]) { const char description[] = "rm passname\n"; int result; - char *path = argv[2]; + char *path = argv[1]; if(!path) usageprint("%s", description); @@ -350,7 +344,6 @@ int cmd_move(int argc, char *argv[]) } } - if(optind < argc) optind++; // for skip "move" if(!argv[optind] || !argv[optind+1]) usageprint("%s", description); diff --git a/src/lpass.c b/src/lpass.c index d1ee817..a466d5d 100644 --- a/src/lpass.c +++ b/src/lpass.c @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) struct cmd_struct *ptr = get_cmd(argv[1]); if(ptr) - return ptr->func(argc, argv); + return ptr->func(--argc, ++argv); - return cmd_showtree(argc, argv); + return cmd_showtree(--argc, ++argv); } \ No newline at end of file -- cgit v1.2.3-18-g5258