This commit is contained in:
Arun Prakash Jana 2020-09-18 20:45:47 +05:30
parent 56dec17840
commit 56621705e8
No known key found for this signature in database
GPG key ID: A75979F35C080412

View file

@ -179,6 +179,12 @@
#define CTX_MAX 8 #define CTX_MAX 8
#endif #endif
#ifdef __APPLE__
#define SED "gsed"
#else
#define SED "sed"
#endif
#define MIN_DISPLAY_COLS ((CTX_MAX * 2) + 2) /* Two chars for [ and ] */ #define MIN_DISPLAY_COLS ((CTX_MAX * 2) + 2) /* Two chars for [ and ] */
#define LONG_SIZE sizeof(ulong) #define LONG_SIZE sizeof(ulong)
#define ARCHIVE_CMD_LEN 16 #define ARCHIVE_CMD_LEN 16
@ -671,11 +677,11 @@ static const char * const toks[] = {
#define P_REPLACE 3 #define P_REPLACE 3
static const char * const patterns[] = { static const char * const patterns[] = {
"sed -i 's|^\\(\\(.*/\\)\\(.*\\)$\\)|#\\1\\n\\3|' %s", SED" -i 's|^\\(\\(.*/\\)\\(.*\\)$\\)|#\\1\\n\\3|' %s",
"sed 's|^\\([^#/][^/]\\?.*\\)$|%s/\\1|;s|^#\\(/.*\\)$|\\1|' " SED" 's|^\\([^#/][^/]\\?.*\\)$|%s/\\1|;s|^#\\(/.*\\)$|\\1|' "
"%s | tr '\\n' '\\0' | xargs -0 -n2 sh -c '%s \"$0\" \"$@\" < /dev/tty'", "%s | tr '\\n' '\\0' | xargs -0 -n2 sh -c '%s \"$0\" \"$@\" < /dev/tty'",
"\\.(bz|bz2|gz|tar|taz|tbz|tbz2|tgz|z|zip)$", "\\.(bz|bz2|gz|tar|taz|tbz|tbz2|tgz|z|zip)$",
"sed -i 's|^%s\\(.*\\)$|%s\\1|' %s", SED" -i 's|^%s\\(.*\\)$|%s\\1|' %s",
}; };
/* Colors */ /* Colors */
@ -2141,7 +2147,7 @@ static bool batch_rename(void)
uint count = 0, lines = 0; uint count = 0, lines = 0;
bool dir = FALSE, ret = FALSE; bool dir = FALSE, ret = FALSE;
char foriginal[TMP_LEN_MAX] = {0}; char foriginal[TMP_LEN_MAX] = {0};
static const char batchrenamecmd[] = "paste -d'\n' %s %s | sed 'N; /^\\(.*\\)\\n\\1$/!p;d' | " static const char batchrenamecmd[] = "paste -d'\n' %s %s | "SED" 'N; /^\\(.*\\)\\n\\1$/!p;d' | "
"tr '\n' '\\0' | xargs -0 -n2 mv 2>/dev/null"; "tr '\n' '\\0' | xargs -0 -n2 mv 2>/dev/null";
char buf[sizeof(batchrenamecmd) + (PATH_MAX << 1)]; char buf[sizeof(batchrenamecmd) + (PATH_MAX << 1)];
int i = get_cur_or_sel(); int i = get_cur_or_sel();
@ -2239,9 +2245,9 @@ static void archive_selection(const char *cmd, const char *archive, const char *
snprintf(buf, CMD_LEN_MAX, snprintf(buf, CMD_LEN_MAX,
#ifdef __linux__ #ifdef __linux__
"sed -ze 's|^%s/||' '%s' | xargs -0 %s %s", curpath, selpath, cmd, archive SED" -ze 's|^%s/||' '%s' | xargs -0 %s %s", curpath, selpath, cmd, archive
#else #else
"tr '\\0' '\n' < '%s' | sed -e 's|^%s/||' | tr '\n' '\\0' | xargs -0 %s %s", "tr '\\0' '\n' < '%s' | "SED" -e 's|^%s/||' | tr '\n' '\\0' | xargs -0 %s %s",
selpath, curpath, cmd, archive selpath, curpath, cmd, archive
#endif #endif
); );