--- asciiview 2001-04-25 17:59:22.000000000 +0200 +++ /usr/bin/asciiview 2010-03-07 18:58:25.000000000 +0100 @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # asciiview - an ascii art image browser script. Front end for aview/aaflip clear() { @@ -7,9 +7,9 @@ } myconvert() { - if anytopnm $1 >/tmp/aview$$.pgm 2>/dev/null ; then + if anytopnm "$1" >/tmp/aview$$.pgm 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 @@ -17,7 +17,7 @@ echo "0 " done } -filenames="" +set -A filenames options="" if [ "$1" = "" ]; then echo "$0 - an ascii art image/animation browser. @@ -45,29 +45,30 @@ shift ;; *) - filenames="$filenames $1" + filenames[${#filenames[@]}]="$1" shift ;; esac done -trap clear 0 +trap clear 0 2 3 9 15 mkfifo /tmp/aview$$.pgm -outfile=/tmp/aview$$.pgm -for name in $filenames ; do -if test -r $name ; then -case $name in +i=0 +while [ $i -lt ${#filenames[@]} ]; do + name=${filenames[$i]} + if [ -r "$name" ]; then + case "$name" in *.fli | *.lfc | *.flic ) PATH="$PATH:." - aaflip $options $name + aaflip $options "$name" ;; *) - myconvert $name >/tmp/aview$$.pgm & + myconvert "$name" > /tmp/aview$$.pgm & pid=$! - PATH="$PATH:." aview $options /tmp/aview$$.pgm kill $pid 2>/dev/null esac else echo "$name could not be opended" fi + i=$((i+1)) done