My problem is that when I started coding my script I encountered several variable scope issues which resulted in the bad habit of exporting almost all my variables.
Now that my code has got quite large I was contemplating cleaning it and part of that is removing a bunch of useless exports. Unfortunately I'm not sure if my knowledge of variable scope is complete. Even after reading a few pages on the subject.
What I know (and hopefully is right):
1-Exporting a variable makes it's content available to subshell processes:
2-Stuff done in parenthesis like this will be affected by removing exports (from what I understand this is the only way to declare / use a subshell):
$(grep "content" <<< $myvar)
3-Variables declared without setting their scope are global:
4-Since I don't declare any local variables I don't have to worry about causing issues within my functions:
local myvar="i don't use this"
1- Is there any point in proceeding with removing the useless exports beside my code not reeking of obvious noobishness?
2- If I do proceed with it, is there anything else I should be aware of that may be affected and break my code? or is there any of my knowledge wrong/incomplete?
3- If you know of a well written (and complete) variable scope reference please share the link.