2 # shprompt -- give a prompt and get an answer satisfying certain criteria
4 # shprompt [-dDfFsy] prompt
5 # s = prompt for string
6 # f = prompt for filename
7 # F = prompt for full pathname to a file or directory
8 # d = prompt for a directory name
9 # D = prompt for a full pathname to a directory
10 # y = prompt for y or n answer
25 while getopts "$OPTS" c
40 ?) echo "usage: $0 [-$OPTS] prompt" 1>&2
46 if [ "$OPTIND" -gt 1 ] ; then
56 if [ -n "$ans" ] ; then
64 # use `fn' and eval so that bash will do tilde expansion for
69 /*) if test -e "$fn" ; then
72 echo "$0: '$fn' does not exist" 1>&2
75 *) if [ "$type" = "path" ] ; then
76 echo "$0: must give full pathname to file" 1>&2
78 if test -e "$fn" ; then
81 echo "$0: '$fn' does not exist" 1>&2
91 # use `fn' and eval so that bash will do tilde expansion for
96 /*) if test -d "$fn" ; then
98 elif test -e "$fn" ; then
99 echo "$0 '$fn' is not a directory" 1>&2
101 echo "$0: '$fn' does not exist" 1>&2
104 *) if [ "$type" = "dirpath" ] ; then
105 echo "$0: must give full pathname to directory" 1>&2
107 if test -d "$fn" ; then
109 elif test -e "$fn" ; then
110 echo "$0 '$fn' is not a directory" 1>&2
112 echo "$0: '$fn' does not exist" 1>&2
130 echo "$0: yes or no required" 1>&2