title: Listing all variables in a file in bash
body: <p>When writing bash scripts I like to write self contained functions which take an argument and perform operations based on that/those argument(s) rather than have global variables being declared in several different places in the code decreasing readability.</p>
  
  <p>The issue arises when you have a function which needs to make use of several variables. Passing something like 10 variables to a function is just plain ugly and for that a simple associative array can be used.</p>
  
  <p>If we want to declare those variables on an external file, the "source" command allows you to import them all in.</p>
  
  <p>The issue then becomes, how do I list the variables declared ONLY inside this file so I can build my associative array with them?
  I have been able to use a combination of "compgen" and a loop to build associative arrays out of a list of variables but how does one list only the variables found inside the file, regardless of what they are called, so I can loop through them and build my array?</p>