nsxiv5c607ad
Pass given file names to key-handler instead of real paths
Misbehaving command lines in the key-handler that rewrite the given files and thus replace symbolic links instead of their targets shall call realpath(1). Fixes issue #205 and reverts commit 92e3b578.
+3 −3
3 files changed
- M Makefile +1 −1
- M exec/key-handler +1 −1
- M main.c +1 −1
| @@ -1,4 +1,4 @@ | |||
| 1 | − | VERSION := git-20161228 | |
| 1 | + | VERSION := git-20170107 | |
| 2 | 2 | ||
| 3 | 3 | PREFIX := /usr/local | |
| 4 | 4 | MANPREFIX := $(PREFIX)/share/man | |
| @@ -18,7 +18,7 @@ readonly TMPFILE="/tmp/sxiv.$$" | |||
| 18 | 18 | ||
| 19 | 19 | rotate() { | |
| 20 | 20 | degree="$1" | |
| 21 | − | while read file; do | |
| 21 | + | tr '\n' \0' | xargs -0 realpath | sort | uniq | while read file; do | |
| 22 | 22 | case "$(file -b -i "$file")" in | |
| 23 | 23 | image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;; | |
| 24 | 24 | *) mogrify -rotate "$degree" "$file" ;; | |
| @@ -525,7 +525,7 @@ void run_key_handler(const char *key, unsigned int mask) | |||
| 525 | 525 | for (f = i = 0; f < fcnt; i++) { | |
| 526 | 526 | if ((marked && (files[i].flags & FF_MARK)) || (!marked && i == fileidx)) { | |
| 527 | 527 | stat(files[i].path, &oldst[f]); | |
| 528 | − | fprintf(pfs, "%s\n", files[i].path); | |
| 528 | + | fprintf(pfs, "%s\n", files[i].name); | |
| 529 | 529 | f++; | |
| 530 | 530 | } | |
| 531 | 531 | } | |