Skip to content

Commit 42eb5d4

Browse files
Fix weird results when combining -script and -e
1 parent 6508671 commit 42eb5d4

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

mathics/main.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -340,25 +340,6 @@ def main() -> int:
340340

341341
definitions.set_line_no(0)
342342

343-
if args.execute:
344-
for expr in args.execute:
345-
evaluation = Evaluation(shell.definitions, output=TerminalOutput(shell))
346-
result = evaluation.parse_evaluate(expr, timeout=settings.TIMEOUT)
347-
shell.print_result(
348-
result, no_out_prompt=True, strict_wl_output=args.strict_wl_output
349-
)
350-
if evaluation.exc_result == Symbol("Null"):
351-
exit_rc = 0
352-
elif evaluation.exc_result == Symbol("$Aborted"):
353-
exit_rc = -1
354-
elif evaluation.exc_result == Symbol("Overflow"):
355-
exit_rc = -2
356-
else:
357-
exit_rc = -3
358-
359-
if not args.persist:
360-
return exit_rc
361-
362343
if args.FILE is not None:
363344
feeder = MathicsFileLineFeeder(args.FILE)
364345
try:
@@ -377,7 +358,26 @@ def main() -> int:
377358

378359
if args.persist:
379360
definitions.set_line_no(0)
380-
else:
361+
elif not args.execute:
362+
return exit_rc
363+
364+
if args.execute:
365+
for expr in args.execute:
366+
evaluation = Evaluation(shell.definitions, output=TerminalOutput(shell))
367+
result = evaluation.parse_evaluate(expr, timeout=settings.TIMEOUT)
368+
shell.print_result(
369+
result, no_out_prompt=True, strict_wl_output=args.strict_wl_output
370+
)
371+
if evaluation.exc_result == Symbol("Null"):
372+
exit_rc = 0
373+
elif evaluation.exc_result == Symbol("$Aborted"):
374+
exit_rc = -1
375+
elif evaluation.exc_result == Symbol("Overflow"):
376+
exit_rc = -2
377+
else:
378+
exit_rc = -3
379+
380+
if not args.persist:
381381
return exit_rc
382382

383383
if not args.quiet:

0 commit comments

Comments
 (0)