#!/bin/sh -e out=$1 shift [ -n "$out" ] || { echo "Usage: mkinitfs outfile" >&2 exit 1 } exit_handler() { local rc=$? trap - EXIT [ $rc -eq 0 ] || rm -f -- $out exit $rc } trap exit_handler HUP PIPE INT TERM QUIT EXIT ( cat < $out