]> Sergey Matveev's repositories - nnn.git/commitdiff
Replaced 'sed' with 'awk'
authorKlZX <azszwymmvqdi@yahoo.com>
Mon, 12 Aug 2019 15:08:02 +0000 (17:08 +0200)
committerKlZX <azszwymmvqdi@yahoo.com>
Mon, 12 Aug 2019 15:08:02 +0000 (17:08 +0200)
src/nnn.c

index fc3f4991796afa1b273efb95fd14391672fa9d6e..f0623f322f5deef074430616d97768a52a34f751 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -1299,12 +1299,7 @@ static void archive_selection(const char *cmd, const char *archive, const char *
 {
        char *buf = (char *)malloc(CMD_LEN_MAX * sizeof(char));
        snprintf(buf, CMD_LEN_MAX,
-#ifdef __linux__
-               "sed -ze 's|^%s/||' '%s' | xargs -0 %s %s", curpath, g_cppath, cmd, archive);
-#else
-               "cat '%s' | tr '\\0' '\n' | sed -e 's|^%s/||' | tr '\n' '\\0' | xargs -0 %s %s",
-               g_cppath, curpath, cmd, archive);
-#endif
+               "awk 'BEGIN{RS=\"\\0\"} {gsub(\"%s/\", \"\", $0); printf \"%%s\\0\", $0}' %s | xargs -0 %s %s", curpath, g_cppath, cmd, archive);
        spawn("sh", "-c", buf, curpath, F_NORMAL);
        free(buf);
 }