source:
trunk/essentials/app-shells/bash/examples/scripts/shprompt@
3506
| Last change on this file since 3506 was 3228, checked in by , 19 years ago | |
|---|---|
| File size: 2.2 KB | |
| Line | |
|---|---|
| 1 | # |
| 2 | # shprompt -- give a prompt and get an answer satisfying certain criteria |
| 3 | # |
| 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 |
| 11 | # |
| 12 | # Chet Ramey |
| 13 | # [email protected] |
| 14 | |
| 15 | type=file |
| 16 | |
| 17 | OPTS=dDfFsy |
| 18 | |
| 19 | succeed() |
| 20 | { |
| 21 | echo "$1" |
| 22 | exit 0 |
| 23 | } |
| 24 | |
| 25 | while getopts "$OPTS" c |
| 26 | do |
| 27 | case "$c" in |
| 28 | s) type=string |
| 29 | ;; |
| 30 | f) type=file |
| 31 | ;; |
| 32 | F) type=path |
| 33 | ;; |
| 34 | d) type=dir |
