#!/bin/sh if [ $# -eq 0 ]; then echo "usage: jpegconv file ..." >&2 exit 1 fi tmpfile=$(mktemp ~/.jpegconv.XXXXXX) || exit 1 for f in "$@"; do jpegtran "$f" >$tmpfile || { rm -f $tmpfile; exit 1; } mv -f $tmpfile "$f" && chmod go+r "$f" done .