Skip to content

Conversation

@saikumar-pujari
Copy link

In this Bash script, mod is declared using local inside the check_even function, which means it is accessible only within that function. Therefore, mod prints correctly inside the function but does not exist outside it. As a result, the final echo $mod prints nothing. Bash does not throw an error for undefined variables; it simply expands them to an empty string.

In this Bash script, mod is declared using local inside the check_even function, which means it is accessible only within that function. Therefore, mod prints correctly inside the function but does not exist outside it. As a result, the final echo $mod prints nothing. Bash does not throw an error for undefined variables; it simply expands them to an empty string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant