aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Mischievous Meerkat <engineerarun@gmail.com>2019-08-12 21:44:54 +0530
committerGravatar GitHub <noreply@github.com>2019-08-12 21:44:54 +0530
commit0cf77c2ac69aadf7e4ed38061f4c428b231b8d46 (patch)
tree636e3cfd5bfa06688f8ceb1fb61bb3c976c9e6cf
parente774634b5babc0c6bb972bdff796f5271671f7dc (diff)
parent1027cd0cf29a418e0d01f27a9e595c3fd516ec9a (diff)
downloadnnn-0cf77c2ac69aadf7e4ed38061f4c428b231b8d46.tar.gz
Merge pull request #322 from KlzXS/awk
Replaced 'sed' with 'awk'
-rw-r--r--src/nnn.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/nnn.c b/src/nnn.c
index fc3f499..f0623f3 100644
--- 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);
}