aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-29 13:53:16 +0530
committerGravatar Arun Prakash Jana <engineerarun@gmail.com>2020-02-29 13:53:16 +0530
commitedb9fe14e4b2762ea0bf31adbd0a24906adf13d0 (patch)
tree221c0c40455609a96183750c3b9aa9ea49312b89
parent0d7d0ca7dbd7c9c297d51f39d06d08181305fc5f (diff)
downloadnnn-edb9fe14e4b2762ea0bf31adbd0a24906adf13d0.tar.gz
Reformat get archive cmd
-rw-r--r--src/nnn.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/nnn.c b/src/nnn.c
index d939eb6..5ece4d0 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1915,14 +1915,18 @@ finish:
static void get_archive_cmd(char *cmd, char *archive)
{
+ uchar i = 3;
+ const char *arcmd[] = {"atool -a", "bsdtar -acvf", "zip -r", "tar -acvf"};
+
if (getutil(utils[UTIL_ATOOL]))
- xstrlcpy(cmd, "atool -a", ARCHIVE_CMD_LEN);
+ i = 0;
else if (getutil(utils[UTIL_BSDTAR]))
- xstrlcpy(cmd, "bsdtar -acvf", ARCHIVE_CMD_LEN);
+ i = 1;
else if (is_suffix(archive, ".zip"))
- xstrlcpy(cmd, "zip -r", ARCHIVE_CMD_LEN);
- else
- xstrlcpy(cmd, "tar -acvf", ARCHIVE_CMD_LEN);
+ i = 2;
+ // else tar
+
+ xstrlcpy(cmd, arcmd[i], ARCHIVE_CMD_LEN);
}
static void archive_selection(const char *cmd, const char *archive, const char *curpath)