#!/bin/bash

set -o errexit
set -o nounset

function show_help ()
{
   cat >&2 <<EOF
usage: $(basename $0) COMMAND [ARG...]

Open a terminal to perform the command.  I will close the terminal 10s
after the command completes, but if you press return before time is
up, I will leave a bash prompt in the terminal.

EOF
   exit 1
}

while getopts ":h" opt
do
   case $opt in
      * ) show_help ;;
   esac
done
shift $(($OPTIND - 1))

if [[ $# < 1 ]]; then
   show_help
fi

CMD="$@"

uxterm -T "$CMD" -e \
   "$CMD; \
   read -p \"Closing soon, RETURN for prompt\" -t 10 && exec bash"

exit 0

