LDP/LDP/guide/docbook/abs-guide/reply.sh

26 lines
524 B
Bash

#!/bin/bash
# reply.sh
# REPLY is the default value for a 'read' command.
echo
echo -n "What is your favorite vegetable? "
read
echo "Your favorite vegetable is $REPLY."
# REPLY holds the value of last "read" if and only if
#+ no variable supplied.
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."
# $REPLY is still set to its previous value because
#+ the variable $fruit absorbed the new "read" value.
echo
exit 0