Repository navigation
WIP: fix(fd): numbered /dev/null spawn delivery + BASH_SOURCE bare-name resolution (#2304, #2302) - #2312
Conversation
The spawn-delivery walk (apply_external_fd_delivery) skipped every numbered redirect whose target is the null device — a guard bundled into the #180 walk before the classified open ladders existed — so `3</dev/null`, `3>/dev/null` and `3<>/dev/null` on an external command left the child with EBADF at the slot. GNU do_redirection_internal hands every file target to redir_open (redir.c:949 do_redirection_internal) and /dev/null is not one of redir.c's special filenames, so it takes the plain open with the kind's flags (redir.c:745 redir_open; `<>` is O_RDWR|O_CREAT, make_cmd.c:682) and the descriptor is delivered like any file's. Drop the null arm from the skip: all three arms below own the null class explicitly and return a real descriptor of the mapped device (open_classified_input's null arm, create_redirect_output's null arm, probe_input_redirect_readwrite's NullDevice fall-through to the raw mapped open). Pins: tests/issue2304_numbered_devnull_spawn_regressions.rs — foreign sh observer for all three kinds, a nested-rubash observer, and a stdio control. Byte-verified against GNU bash 5.3.20. Refs #2304
…ripts A script invoked by bare name and found through PATH recorded the bare name in BASH_SOURCE[0]. GNU records the path actually opened on both invocation faces: - command face: execute_disk_command resolves the word through find_user_command (findcmd.c:247 find_user_command; findcmd.c:623 find_user_command_in_path returns the PATH-joined full_path) and shell_execve's ENOEXEC re-exec replaces the typed word with that resolved name (execute_cmd.c:6237-6260 shell_execve), so $0 (shell.c:1613), the BASH_SOURCE push (variables.c:5718 push_source, via shell.c:1640) and the in-script diagnostic prefix are all the resolved path; - program face: open_shell_script replaces filename with the PATH find (shell.c:1595-1597) and push_source records it (shell.c:1640), while dollar_vars[0] keeps the spelled name (shell.c:1613). A word carrying a slash is never PATH-searched (findcmd.c:385) and keeps its typed spelling on both faces. execute_enoexec_shell_script now seeds the reader name from the find_user_command result (program) for slash-less words; in main.rs run_script_file_with_init, when find_script_on_path supplies the file, __RUBASH_SCRIPT_NAME (the reader-name carrier seeding BASH_SOURCE and diagnostic names) takes the found name while BASH_ARGV0 keeps the spelled name. Pins: tests/issue2302_bash_source_bare_name_regressions.rs — command-face bare/direct/diagnostic cells, program-face bare/diagnostic cells, slash-spelling and not-in-PATH controls. Byte-verified against GNU bash 5.3.20. Refs #2302
|
Collector adjudication of the CI red (Compatibility CLI tests): the single failure, |
Refs #2304, Refs #2302 — two small diagnosed fixes from the fd/invocation tail wave. One commit per issue. Local commits only: push pending credential restore (gh token 401 at delivery time).
#2304 — numbered /dev/null redirects skipped on the spawn face
apply_external_fd_delivery's skip bundle (from #180) dropped every numbered redirect whose targetis_null_device, sosh -c '…' 3</dev/null/3>/dev/null/3<>/dev/nullgave the child EBADF at the slot. GNU hands every file target toredir_open(redir.c:949) and /dev/null takes the plain open with the kind's flags (redir.c:745;<>= O_RDWR|O_CREAT, make_cmd.c:682). The fix removes the null arm from the skip — all three ladders below it own the null class explicitly and return a real descriptor of the mapped device (open_classified_input's null arm,create_redirect_output's null arm,probe_input_redirect_readwrite's NullDevice fall-through).Pins:
tests/issue2304_numbered_devnull_spawn_regressions.rs(5) — foreignshobserver for all three kinds, nested-rubash observer, stdio control. Red on master, green with the fix; probe table byte-identical to GNU bash 5.3.20.#2302 — bare-name PATH invocation recorded the bare name in BASH_SOURCE[0]
GNU records the path actually opened on both faces (command face: find_user_command's full_path replaces the typed word in shell_execve's ENOEXEC re-exec, execute_cmd.c:6237-6260; program face: open_shell_script replaces filename with the PATH find, shell.c:1595-1597, push_source at shell.c:1640), while $0 splits by face (command face resolved; program face as spelled, shell.c:1613).
execute_enoexec_shell_script: a slash-less word now seeds the reader name from thefind_user_commandresult (program) instead of the typed word; slash words unchanged.main.rs run_script_file_with_init: whenfind_script_on_pathsupplies the file,__RUBASH_SCRIPT_NAME(the reader-name carrier seeding BASH_SOURCE + diagnostic names) takes the found name;BASH_ARGV0($0) keeps the spelled name.Pins:
tests/issue2302_bash_source_bare_name_regressions.rs(7) — command-face bare/direct/err-prefix, program-face bare/err-prefix, slash-spelling control, not-in-PATH refusal control. Red on master, green with the fix; probe table byte-identical to GNU bash 5.3.20.Verification (collector-local, scrubbed fd environment)
--test regression: 221 passed + exactly the 6 known local stock reds (master-red locally, green in CI)