diff options
| author | 2017-04-03 23:33:31 +0530 | |
|---|---|---|
| committer | 2017-04-03 23:33:31 +0530 | |
| commit | 30c8828e42e6e14fc3704a0e91fa2a5610296dc2 (patch) | |
| tree | a1c099e9c679bc59d7a315bc8ff0fadfdbdeffe8 | |
| parent | 4b660297626ae92bc49be82118e40732354fe24f (diff) | |
| download | nnn-30c8828e42e6e14fc3704a0e91fa2a5610296dc2.tar.gz | |
Use double quotes to handle file names with spaces
Remove dependency on cut.
| -rw-r--r-- | nnn.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -779,7 +779,7 @@ show_stats(char* fpath, char* fname, struct stat *sb) if (S_ISREG(sb->st_mode)) { /* Show file(1) output */ - sprintf(buf, "file -b %s 2>&1", fpath); + sprintf(buf, "file -b \"%s\" 2>&1", fpath); p = get_output(buf, PATH_MAX + 48); if (p) { printw("\n\n "); @@ -796,16 +796,30 @@ show_stats(char* fpath, char* fname, struct stat *sb) } /* Show md5 */ - sprintf(buf, "openssl md5 %s 2>&1 | cut -d' ' -f2", fpath); + sprintf(buf, "openssl md5 \"%s\" 2>&1", fpath); p = get_output(buf, PATH_MAX + 48); - if (p) + if (p) { + p = xmemrchr(buf, ' ', strlen(buf)); + if (!p) + p = buf; + else + p++; + printw("\n md5: %s", p); + } /* Show sha256 */ - sprintf(buf, "openssl sha256 %s 2>&1| cut -d' ' -f2", fpath); + sprintf(buf, "openssl sha256 \"%s\" 2>&1", fpath); p = get_output(buf, PATH_MAX + 48); - if (p) + if (p) { + p = xmemrchr(buf, ' ', strlen(buf)); + if (!p) + p = buf; + else + p++; + printw(" sha256: %s", p); + } } /* Show exit keys */ |