Factored out list of prompts into a single variable for ease of maintenance.
1 parent 00a35d8 commit 7cec515ed82d16ae4545877d40817b3c5840748d
@tundra tundra authored on 7 Oct 2010
Showing 1 changed file
View
6
tpromptuser.sh
#!/bin/sh
# promptuser.sh - User Prompting From Shell With validation
# Copyright (c) 2010, TundraWare Inc, Des Plaines, IL USA
# All Rights Reserved
# $Id: tpromptuser.sh,v 1.103 2010/10/07 18:58:50 tundra Exp $
# $Id: tpromptuser.sh,v 1.104 2010/10/07 19:12:17 tundra Exp $
 
# Loop through a set of questions for the user to answer, storing
# their response back into the prompt variable itself.
#
baz="Would you like to baz?${DL}n${DL}${YN} yup"
bat="Would you like to bat?${DL}${DL}nope"
 
 
PROMPTLIST="foo bar baz bat"
 
# Display the records for purposes of this example only
 
echo "Before: foo->$foo bar->$bar baz->$baz bat->$bat"
 
# Actual Prompting Logic
#####
 
 
for x in "foo" "bar" "baz" "bat"
for x in $PROMPTLIST
do
eval record=\$$x # Get the prompt record
IFS=$DL # Get individual fields
read prompt default answers <<EOF