Skip to content

Commit c1e7dd3

Browse files
committed
core/main_loop: Mark the "eval" internal file as persistent
This fixes the following issue: $ cat source.osh exec 10>out echo hello>&10 cat out $ bin/osh --eval source.osh hello oils I/O error (main): Bad file descriptor Signed-off-by: Andrii Sultanov <[email protected]>
1 parent e107265 commit c1e7dd3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/main_loop.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,13 +459,16 @@ def EvalFile(
459459
ok: whether processing should continue
460460
"""
461461
try:
462-
f, _ = fd_state.Open(fs_path)
462+
f, fd = fd_state.Open(fs_path, persistent=True)
463463
except (IOError, OSError) as e:
464464
print_stderr("%s: Couldn't open %r for --eval: %s" %
465465
(lang, fs_path, posix.strerror(e.errno)))
466466
return False, -1
467467

468-
line_reader = reader.FileLineReader(f, cmd_ev.arena)
468+
file_line_reader = reader.FileLineReader(f, cmd_ev.arena)
469+
line_reader = file_line_reader
470+
fd_state.SetCallback(fd, file_line_reader)
471+
469472
c_parser = parse_ctx.MakeOshParser(line_reader)
470473

471474
# TODO:

0 commit comments

Comments
 (0)