def list_vars(script_path, ignore=IGNORE_DEFAULT):
if path.isfile(script_path):<EOL><INDENT>input = ("""<STR_LIT>""" % script_path +<EOL>"""<STR_LIT>""")<EOL>cmd = "<STR_LIT>".split()<EOL>p = Popen(cmd, stdout=PIPE, stdin=PIPE, stderr=PIPE)<EOL>stdout_data, stderr_data = p.communicate(input=input)<EOL>if stderr_data:<EOL><INDENT>raise ShellScriptException(script_path, stderr_data)<EOL><DEDENT>else:<EOL><INDENT>lines = stdout_data.split()<EOL>return [elt for elt in lines if elt not in ignore]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise _noscripterror(script_path)<EOL><DEDENT>
Given a shell script, returns a list of shell variable names.
Note: this method executes the script, so beware if it contains side-effects.
:param script_path: Path the a shell script
:type script_path: str or unicode
:param ignore: variable names to ignore.  By default we ignore variables
                that env injects into the script's environment.
                See IGNORE_DEFAULT.
:type ignore: iterable
:return: Key value pairs representing the environment variables defined
        in the script.
:rtype: list