mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-06 01:10:57 +01:00
compile scripts with exec mode instead of single
This commit is contained in:
parent
ad8fd1dda1
commit
5303d6294b
1 changed files with 4 additions and 4 deletions
|
@ -33,14 +33,14 @@ def main(argv=None):
|
|||
# run a script contained in a file
|
||||
if os.path.isfile(args.file):
|
||||
with open(args.file) as f:
|
||||
for line in f:
|
||||
shell.default(line)
|
||||
code = shell.execer.compile(f.read(), mode='exec')
|
||||
shell.execer.exec(code, mode='exec')
|
||||
else:
|
||||
print('xonsh: {0}: No such file or directory.'.format(args.file))
|
||||
elif not sys.stdin.isatty():
|
||||
# run a script given on stdin
|
||||
for line in sys.stdin:
|
||||
shell.default(line)
|
||||
code = shell.execer.compile(sys.stdin.read(), mode='exec')
|
||||
shell.execer.exec(code, mode='exec')
|
||||
else:
|
||||
# otherwise, enter the shell
|
||||
shell.cmdloop()
|
||||
|
|
Loading…
Add table
Reference in a new issue