Skip to content

Commit 5d29888

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

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

core/shell.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,18 @@ def SourceStartupFile(
151151
# Bash also has --login.
152152

153153
try:
154-
f, _ = fd_state.Open(rc_path)
154+
f, fd = fd_state.Open(rc_path, persistent=True)
155155
except (IOError, OSError) as e:
156156
# TODO: Could warn about nonexistent explicit --rcfile?
157157
if e.errno != ENOENT:
158158
raise # Goes to top level. Handle this better?
159159
return
160160

161161
arena = parse_ctx.arena
162-
rc_line_reader = reader.FileLineReader(f, arena)
162+
file_line_reader = reader.FileLineReader(f, arena)
163+
rc_line_reader = file_line_reader
164+
fd_state.SetCallback(fd, file_line_reader)
165+
163166
rc_c_parser = parse_ctx.MakeOshParser(rc_line_reader)
164167

165168
with alloc.ctx_SourceCode(arena, source.MainFile(rc_path)):

0 commit comments

Comments
 (0)