I'm new to bash. I'm confused about the way functions work in this language.
I have written this code:
#!/usr/bin/env sh
choice_func() {
echo "$choice"
}
echo "Enter your choice:"
read choice
choice_func
While investigating my code, I realized that I have forgotten to send the value of choice as input when calling choice_func(). But it works properly! how it is possible that the function has not been given the input but can echo it?