#!/bin/sh # # xbm-cmd $i pbmplus-command args... # Perform a pbmplus command on the xbm file given. # # Anthony Thyssen 16 Dec 1993 anthony@cit.gu.edu.au # i="$1" shift exec &2 "xbm-cmd: Unable to read \"$i\"" exit 10; fi if [ ! -w "$i" ]; then echo >&2 "xbm-cmd: Unable to write \"$i\"" exit 10; fi # --- find out the type --- name="`basename $i`" suffix="`expr "$name" : '.*\.\([^.]*\)'`" name="`expr "$name" : '\([^.]*\)'`" # --- convert to PbmPlus format --- case "$suffix" in xbm) sed 's/unsigned //' "$i" | xbmtopbm > $TMP1 ;; xpm|recol) sed -f $HOME/bin/bmaps/x2p.sed "$i" | xpmtoppm > $TMP1 ;; *) echo >&2 "Unknown suffix for \"$i\"" exit 0 ;; esac # --- execute the command given --- "$@" < $TMP1 > $TMP2 if [ ! -f $TMP2 -o ! -s $TMP2 ]; then echo >&2 "Command failed for \"$i\"" exit 0; fi # --- convert back --- case "$suffix" in xbm) pbmtoxbm < $TMP2 | sed 's/static *char/static unsigned char/; s/noname\([[_]\)/'"$name"'\1/' > "$i" ;; xpm|recol) ppmtoxpm < $TMP2 2>/dev/null | xpm-fix -o "$i" ;; esac 2>/dev/null