#! /bin/sh default="$2" while : do echo "$1 [$2]? " | tr -d '\012' >/dev/tty # echo -n, semiportably read answer case "$answer" in !*) cmd="`expr \"$answer\" : '!\(.*\)'`" trap : 2 ${SHELL-/bin/sh} -c "$cmd" >/dev/tty trap 2 echo '!' >/dev/tty ;; *) break ;; # NOTE BREAK OUT esac done case "$answer" in '') answer="$default" ;; -) answer= ;; esac echo "$answer"