mirror of
https://github.com/jarun/nnn.git
synced 2024-11-24 11:51:27 +00:00
Retain control chars when invoking external utils
This commit is contained in:
parent
08d87405d0
commit
a3852a6cb1
34
nnn.c
34
nnn.c
|
@ -1103,7 +1103,9 @@ show_stats(char* fpath, char* fname, struct stat *sb)
|
||||||
|
|
||||||
if (S_ISREG(sb->st_mode)) {
|
if (S_ISREG(sb->st_mode)) {
|
||||||
/* Show file(1) output */
|
/* Show file(1) output */
|
||||||
sprintf(buf, "file -b \"%s\" 2>&1", fpath);
|
strcpy(buf, "file -b \"");
|
||||||
|
xstrlcpy(buf + strlen(buf), fpath, strlen(fpath) + 1);
|
||||||
|
strcat(buf, "\" 2>&1");
|
||||||
p = get_output(buf, PATH_MAX + 16);
|
p = get_output(buf, PATH_MAX + 16);
|
||||||
if (p) {
|
if (p) {
|
||||||
dprintf(fd, "\n\n ");
|
dprintf(fd, "\n\n ");
|
||||||
|
@ -1135,14 +1137,17 @@ show_mediainfo(const char* fpath, int full)
|
||||||
{
|
{
|
||||||
static char buf[MAX_CMD_LEN];
|
static char buf[MAX_CMD_LEN];
|
||||||
|
|
||||||
snprintf(buf, MAX_CMD_LEN, "which mediainfo");
|
strcpy(buf, "which mediainfo");
|
||||||
if (get_output(buf, MAX_CMD_LEN) == NULL)
|
if (get_output(buf, MAX_CMD_LEN) == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
strcpy(buf, "mediainfo \"");
|
||||||
|
xstrlcpy(buf + strlen(buf), fpath, strlen(fpath) + 1);
|
||||||
if (full)
|
if (full)
|
||||||
sprintf(buf, "mediainfo -f \"%s\" 2>&1 | %s", fpath, xgetenv("PAGER", "less"));
|
strcat(buf, "\" -f ");
|
||||||
else
|
else
|
||||||
sprintf(buf, "mediainfo \"%s\" 2>&1 | %s", fpath, xgetenv("PAGER", "less"));
|
strcat(buf, "\" ");
|
||||||
|
sprintf(buf + strlen(buf), "2>&1 | %s", xgetenv("PAGER", "less"));
|
||||||
|
|
||||||
return system(buf);
|
return system(buf);
|
||||||
}
|
}
|
||||||
|
@ -1566,9 +1571,9 @@ nochange:
|
||||||
|
|
||||||
/* If NNN_OPENER is set, use it */
|
/* If NNN_OPENER is set, use it */
|
||||||
if (opener) {
|
if (opener) {
|
||||||
snprintf(cmd, MAX_CMD_LEN,
|
sprintf(cmd, "%s \"", opener);
|
||||||
"%s \"%s\" > /dev/null 2>&1",
|
xstrlcpy(cmd + strlen(cmd), newpath, strlen(newpath) + 1);
|
||||||
opener, newpath);
|
strcat(cmd, "\" > /dev/null 2>&1");
|
||||||
r = system(cmd);
|
r = system(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1576,8 +1581,9 @@ nochange:
|
||||||
/* Play with nlay if identified */
|
/* Play with nlay if identified */
|
||||||
mime = getmime(dents[cur].name);
|
mime = getmime(dents[cur].name);
|
||||||
if (mime) {
|
if (mime) {
|
||||||
snprintf(cmd, MAX_CMD_LEN, "nlay \"%s\" %s",
|
strcpy(cmd, "nlay \"");
|
||||||
newpath, mime);
|
xstrlcpy(cmd + strlen(cmd), newpath, strlen(newpath) + 1);
|
||||||
|
sprintf(cmd + strlen(cmd), "\" %s", mime);
|
||||||
exitcurses();
|
exitcurses();
|
||||||
r = system(cmd);
|
r = system(cmd);
|
||||||
initcurses();
|
initcurses();
|
||||||
|
@ -1586,8 +1592,9 @@ nochange:
|
||||||
|
|
||||||
/* If nlay doesn't handle it, open plain text
|
/* If nlay doesn't handle it, open plain text
|
||||||
files with vi, then try NNN_FALLBACK_OPENER */
|
files with vi, then try NNN_FALLBACK_OPENER */
|
||||||
snprintf(cmd, MAX_CMD_LEN,
|
strcpy(cmd, "file -b \"");
|
||||||
"file \"%s\"", newpath);
|
xstrlcpy(cmd + strlen(cmd), newpath, strlen(newpath) + 1);
|
||||||
|
strcat(cmd, "\"");
|
||||||
if (get_output(cmd, MAX_CMD_LEN) == NULL)
|
if (get_output(cmd, MAX_CMD_LEN) == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1598,8 +1605,9 @@ nochange:
|
||||||
initcurses();
|
initcurses();
|
||||||
continue;
|
continue;
|
||||||
} else if (fb_opener) {
|
} else if (fb_opener) {
|
||||||
snprintf(cmd, MAX_CMD_LEN, "%s \"%s\" > /dev/null 2>&1",
|
sprintf(cmd, "%s \"", fb_opener);
|
||||||
fb_opener, newpath);
|
xstrlcpy(cmd + strlen(cmd), newpath, strlen(newpath) + 1);
|
||||||
|
strcat(cmd, "\" > /dev/null 2>&1");
|
||||||
r = system(cmd);
|
r = system(cmd);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue