#!/bin/sh -e PROG=mkinitfs Fatal() { echo "$PROG: $*" >&2 exit 1 } TEMP= exit_handler() { local rc=$? trap - EXIT [ -z "$TEMP" ] || rm -f -- "$TEMP" [ $rc -eq 0 ] || rm -f -- "$OUT" exit $rc } [ -n "$1" ] || Fatal "Usage: mkinitfs outfile" OUT="$1"; shift trap exit_handler HUP PIPE INT TERM QUIT EXIT TEMP=`mktemp -t mkinitfs.XXXXXXXXXX` || Fatal "Failed to create temporary file." ( cat < "$TEMP" gzip -c < "$TEMP" > "$OUT"