def source_foreign(args, stdin=None):
parser = _ensure_source_foreign_parser()<EOL>ns = parser.parse_args(args)<EOL>if ns.prevcmd is not None:<EOL><INDENT>pass  <EOL><DEDENT>elif os.path.isfile(ns.files_or_code[<NUM_LIT:0>]):<EOL><INDENT>ns.prevcmd = '<STR_LIT>'.format(ns.sourcer, '<STR_LIT>'.join(ns.files_or_code))<EOL><DEDENT>elif ns.prevcmd is None:<EOL><INDENT>ns.prevcmd = '<STR_LIT:U+0020>'.join(ns.files_or_code)  <EOL><DEDENT>fsenv = foreign_shell_data(shell=ns.shell, login=ns.login,<EOL>interactive=ns.interactive,<EOL>envcmd=ns.envcmd,<EOL>aliascmd=ns.aliascmd,<EOL>extra_args=ns.extra_args,<EOL>safe=ns.safe, prevcmd=ns.prevcmd,<EOL>postcmd=ns.postcmd,<EOL>funcscmd=ns.funcscmd,<EOL>sourcer=ns.sourcer,<EOL>use_tmpfile=ns.use_tmpfile,<EOL>seterrprevcmd=ns.seterrprevcmd,<EOL>seterrpostcmd=ns.seterrpostcmd)<EOL>if fsenv is None:<EOL><INDENT>raise RuntimeError("<STR_LIT>".format(ns.prevcmd), <NUM_LIT:1>)<EOL><DEDENT>env = os.environ.copy()<EOL>for k, v in fsenv.items():<EOL><INDENT>if k in env and v == env[k]:<EOL><INDENT>continue  <EOL><DEDENT>env[k] = v<EOL><DEDENT>for k in os.environ: <EOL><INDENT>if k not in fsenv:<EOL><INDENT>env.pop(k, None)<EOL><DEDENT><DEDENT>return env<EOL>
Sources a file written in a foreign shell language.