aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-04-17 12:19:33 +0530
committersinanmohd <sinan@sinanmohd.com>2024-04-17 12:30:55 +0530
commit091ecbe6f0572935d94752ae28823ad2a3eadd39 (patch)
treeab4f41c54b70785df11fd85995ed718d527b5530
parent47166b41e05090c595de633c67dfe8ae4cb19bc0 (diff)
c: improve error reporting
-rw-r--r--src/libnpass/libnpass.c2
-rw-r--r--src/npass/npass.c7
2 files changed, 6 insertions, 3 deletions
diff --git a/src/libnpass/libnpass.c b/src/libnpass/libnpass.c
index fd6e447..62cbc5e 100644
--- a/src/libnpass/libnpass.c
+++ b/src/libnpass/libnpass.c
@@ -163,7 +163,7 @@ static int openstore(const char *spath, DIR **dirp)
store_type = pass_store_type(spath);
if (store_type != PASS_STORE_DIR)
- return_err(-EINVAL, "%s Not a passwordstore path", spath);
+ return (store_type < 0) ? store_type : -EINVAL;
if (spath) {
r = snprintf(abs_path, sizeof(abs_path), "%s/%s", pass_dir,
diff --git a/src/npass/npass.c b/src/npass/npass.c
index f78df9d..8fa7113 100644
--- a/src/npass/npass.c
+++ b/src/npass/npass.c
@@ -8,9 +8,9 @@
#include "util.h"
#define return_invalid_usage(err) \
- return_err(err, "%s", "Invalid usage, try $pass help")
+ return_err(err, "%s", "Invalid usage, try `pass help`")
-#define DEF_DEPTTH 16;
+#define DEF_DEPTTH 16
#define BLUE "\e[0;34m"
#define NCOL "\e[0m"
@@ -227,6 +227,9 @@ int main(int argc, char *argv[])
if (!--argc) {
r = ls(NULL, 0);
} else if (!strcmp("help", *argv)) {
+ if (argc != 1)
+ return_invalid_usage(EXIT_FAILURE);
+
print_usage();
} else if (!strcmp("init", *argv)) {
if (argc != 2)