I simplified my bash script to the scope of the problem. I was wondering how come when I do this...
#!/bin/bash
read -p "Please enter your name: " name
function test()
{
while true
do
echo $name
done
}
echo $(test)
the echo command doesn't loop the name in the terminal. However, if I were to remove the function and have the while loop by itself like so....
#!/bin/bash
read -p "Please enter your name: " name
while true
do
echo $name
done
It would work. Or if I do this, it will also work
#!/bin/bash
read -p "Please enter your name: " name
function test()
{
echo $name
}
echo $(test)
What's causing the echo command to not to not display the name. This only happens when the echo command is inside a while loop whilst being inside a function.