Skip to content

[bug] exec with a command treats >&fd / >&- as output to a file named fd / - #2803

Closed

Description

@caomengxuan666

Repro

exec echo hi >&2

Expected (GNU bash 5.3.20)

hi goes to stderr; no file is created; the shell continues (exec with a command does not replace the shell).

Actual (rubash master 78e7d86)

A file literally named 2 is created containing hi; nothing reaches stderr. Likewise exec echo hi >&- creates a file literally named - instead of closing stdout for the command, and exec echo hi >&1 / exec echo hi 2>err.txt >&- style fd-duplication/close forms show the same file-creation direction (morph forms mB10/mB12/mB14/mB18/mB19/mB20 all DIFF).

Boundary (both shells agree)

Bare exec (no command) with >&fd / >&-, the command builtin with the same redirections, >&- / &>- outside exec, ordinary > file redirection, and <&- all behave per GNU. The breakage is specific to exec-with-a-command plus fd-duplication/close redirections.

Regression seed:

exec echo hi >&2
# GNU: hi on stderr, no file created. rubash (pre-fix): file named '2' created, hi in the file.
# Assertable form: run in an empty dir, then check no file named '2' exists and stderr got 'hi'.

Found by diff-hunt round r64 (glob/case + procsub/coproc), verdict on a fresh master build, two passes byte-identical. Dedup: no open/closed exec-redirection issue covers fd-duplication-as-filename under exec-with-command (#1413 is exec persistent stdin redirections, #1687 is numbered fds for bare builtins — different mechanisms).

Activity

  1. added
    bug
    gnu-baseline
    area:fd
    on Nov 4, 2026
  2. caomengxuan666 commented on Nov 10, 2026

    @caomengxuan666
    MemberAuthor

    由 PR #3144 合入关闭(squash d4f7d94,2026-11-10T07:36:19Z)。队长复核 PASS(卷宗 review-3144/):九文件 +1422/−268,冲突消解合并经四核(无冲突标记/master 功能在位/删除意图未复活/无改动被吞),四单钉头复跑 37/37(2395 7/7、2635 12/12、2803 6/6、2821 12/12),lib 双边 1207/0/4 同数、-D warnings 干净,合入头 CI 10 过 1 跳零红。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:fdbuggnu-baseline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions