compile scripts with exec mode instead of single

This commit is contained in:
adam j hartz 2015-03-18 19:43:23 -04:00
parent ad8fd1dda1
commit 5303d6294b

View file

@ -33,14 +33,14 @@ def main(argv=None):
# run a script contained in a file # run a script contained in a file
if os.path.isfile(args.file): if os.path.isfile(args.file):
with open(args.file) as f: with open(args.file) as f:
for line in f: code = shell.execer.compile(f.read(), mode='exec')
shell.default(line) shell.execer.exec(code, mode='exec')
else: else:
print('xonsh: {0}: No such file or directory.'.format(args.file)) print('xonsh: {0}: No such file or directory.'.format(args.file))
elif not sys.stdin.isatty(): elif not sys.stdin.isatty():
# run a script given on stdin # run a script given on stdin
for line in sys.stdin: code = shell.execer.compile(sys.stdin.read(), mode='exec')
shell.default(line) shell.execer.exec(code, mode='exec')
else: else:
# otherwise, enter the shell # otherwise, enter the shell
shell.cmdloop() shell.cmdloop()