summaryrefslogtreecommitdiff
blob: 6d547ea0f13ad075a87c3c3c2e6b24f0f383d47f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
Support spaces in filenames (bug #39207) based on a patch from
kyberneticist AT yahoo DOT com with additional fixes to address bug
#293654 by Kevin McCarthy <signals@gentoo.org>

Fix insecure temporary file permissions (bug #235808) based on a patch from
Robert Buchholz <rbu@gentoo.org>

Fix ignored interactive keyboard commands when aview is called from the
asciiview script (bug #293654) by Kevin McCarthy <signals@gentoo.org>

Rollup patch created by Kevin McCarthy <signals@gentoo.org>

--- a/asciiview
+++ b/asciiview
@@ -3,13 +3,13 @@
 clear()
 {
   kill $! 2>/dev/null
-  rm -f /tmp/aview$$.pgm 2>/dev/null
+  rm -rf $tmpdir 2>/dev/null
 }
 myconvert()
 {
-   if anytopnm $1 >/tmp/aview$$.pgm 2>/dev/null ; then
+   if anytopnm "$1" >"$2" 2>/dev/null ; then
      exit
-   elif convert -colorspace gray $1 pgm:- 2>/dev/null ; then
+   elif convert -colorspace gray "$1" pgm:- 2>/dev/null ; then
      exit
    fi
    echo "Failed to convert file format to PNM by both convert and anytopnm" >&2
@@ -44,27 +44,34 @@
       options="$options $1"
       shift
       ;;
-    *) 
-      filenames="$filenames $1"
+    *)
+      if [ "$filenames" = "" ]
+      then
+        filenames=$1   #avoid leading null
+      else
+        filenames=$(echo -e "$filenames\n$1")
+      fi
       shift
       ;;
   esac
 done
 trap clear 0
-mkfifo /tmp/aview$$.pgm
-outfile=/tmp/aview$$.pgm
-for name in $filenames ; do
-if test -r $name ; then
-case $name in
+tmpdir=`mktemp -t -d`
+outfile=$tmpdir/aview.pgm
+mkfifo $outfile
+exec 3<&0
+echo "$filenames" | while read name; do
+if test -r "$name" ; then
+case "$name" in
 *.fli | *.lfc | *.flic )
   PATH="$PATH:."
-  aaflip $options $name
+  aaflip $options "$name"
   ;;
 *)
-  myconvert $name >/tmp/aview$$.pgm &
+  myconvert "$name" "$outfile" >"$outfile" &
   pid=$!
   PATH="$PATH:."
-  aview  $options /tmp/aview$$.pgm
+  aview  $options $outfile <&3
   kill $pid 2>/dev/null
 esac
 else