You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] Empty redirection target misreported as 'ambiguous redirect' (GNU: ': No such file or directory' for >, raw-word 'Bad file descriptor' for >&) #265
Found by: wt5/audit source lane (2026-09-28), script-file-verified against WSL GNU Bash 5.3.0.
Summary: When a redirection word expands to the EMPTY STRING, GNU does not call it ambiguous — it proceeds: > "" becomes open("") failing ENOENT, and >& "" becomes a dup of an empty fd spec failing EBADF (printing the unexpanded word). rubash classifies every empty expansion as ambiguous redirect and prints the quoted literal.
GNU C source owner:
third_party/bash/redir.c:895-930 (do_redirection_internal file-open cases): redirectee_word = redirection_expand(...); AMBIGUOUS_REDIRECT is returned only when redirection_expand returns NULL — i.e. the word expanded to MORE THAN ONE field (redir.c:298 redirection_expand -> w_expand multi-word). An empty single-word expansion is returned as a valid empty filename.
redir.c:135-197redirection_error(): for open errors prints the EXPANDED filename (: No such file or directory); for r_duplicating_output_word EBADF with redirector==1 it prints the RAW word ("$unsetv": Bad file descriptor, redir.c:172-176).
Reproducer (tests/fixtures/audit/a2-iso.sh case 5; raw: target/issue-suites/results/source-audit/out/a2-iso.diff):
echo oops >"";echo"rc=$?"echo oops2 >"$unsetv";echo"rc=$?"echo oops3 >&"$unsetv";echo"rc=$?"
v="a b";echo multi >$v;echo"rc=$?"# control: multi-word stays ambiguous on both
GNU 5.3.0: rc=1 with stderr
: No such file or directory
: No such file or directory
"$unsetv": Bad file descriptor
$v: ambiguous redirect <- only the truly-multi-word case
Rubash owner:src/executor/redirection.rs:76 reject_ambiguous_redirects and :118-156 — the NULL/empty branch comment cites report_ambiguous_redirect but treats empty-string expansion as ambiguous, and the diagnostic prints the raw quoted operand instead of the expanded value.
Classification: rubash-caused; same diagnostic-hygiene family as #250 (diagnostics bypassing applied fd 2) but a different wrong-invariant (empty != multi-word). Scripts probing redirectability with unset variables get the wrong errno story.
Activity
docs: source-audit lane (wt5/audit) — GNU C vs Rust owner gap audit, …
fd/io family: move-fd dups, <> create, empty-target diagnostics, bad-…
caomengxuan666 commentedon Sep 27, 2026
已修复并合入 master(commit 3aec2a83,lane wt6/fdio;GNU 引用与 14 探针矩阵/真基线切片验证见提交——redir/read/heredoc/procsub 全 0 差异,regression 24/24)。感谢报告!