2001-07-10 14:25:50 +00:00
|
|
|
#!/bin/bash
|
2003-11-03 16:25:16 +00:00
|
|
|
# reply.sh
|
|
|
|
|
|
|
|
# REPLY is the default value for a 'read' command.
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo -n "What is your favorite vegetable? "
|
|
|
|
read
|
|
|
|
|
|
|
|
echo "Your favorite vegetable is $REPLY."
|
2003-09-15 14:30:43 +00:00
|
|
|
# REPLY holds the value of last "read" if and only if
|
|
|
|
#+ no variable supplied.
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo -n "What is your favorite fruit? "
|
|
|
|
read fruit
|
|
|
|
echo "Your favorite fruit is $fruit."
|
|
|
|
echo "but..."
|
|
|
|
echo "Value of \$REPLY is still $REPLY."
|
2003-09-15 14:30:43 +00:00
|
|
|
# $REPLY is still set to its previous value because
|
|
|
|
#+ the variable $fruit absorbed the new "read" value.
|
2001-07-10 14:25:50 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
exit 0
|