#!/bin/sh PRG="/usr/sbin/faxsend" PREFIX="/tmp/faxsend-$$" printf '# Automatically generated batch\n' > $PREFIX.batch printf 'set pagination off\n' >> $PREFIX.batch printf 'set logging file %s\n' $PREFIX.log >> $PREFIX.batch printf 'set logging redirect on\n' >> $PREFIX.batch printf 'set logging on\n' >> $PREFIX.batch printf 'handle all nostop print pass' >> $PREFIX.batch printf 'handle SIGSEGV stop print pass' >> $PREFIX.batch printf 'run\n' >> $PREFIX.batch printf 'thread apply all bt\n' >> $PREFIX.batch printf 'backtrace\n' >> $PREFIX.batch printf 'print this\n' >> $PREFIX.batch printf 'generate-core-file %s\n' $PREFIX.core >> $PREFIX.batch gdb -return-child-result -batch -x $PREFIX.batch --args "$PRG" "$@" RET=$? rm $PREFIX.batch exit $RET