BASH hangman: loop which adds the character to the variable if it matches
I can't seem to get this loop to output the secret_word variable with the correctly guessed letter replaced within the variable, this is my code can sum please tell me where i am goin worng..
function compare_letter () {
oldsecret_word=$secret_word
word_length=${#random_word}
secret_word=""
i=0
while [ $i -eq $word_length ]
do
if [ "$letter"=$(echo $random_word | cut -c$(($i+1))) ]
then
$secret_word+="$letter"
else
$secret_word+="-"
fi
done
}
|