Skip to content

[bug] Parser rejects bare <> redirect followed by process substitution: 'read -rt 0.1 <> <(:)' is a syntax error (GNU runs it) #325

Closed

Description

@caomengxuan666

Found by ecosweep3 lane (pure-bash-bible corpus, section 074 'Use read as an alternative to sleep'; carrier release build of 6106961).

Reproducer (target/probe-out/p7.sh)

read_sleep() {
    read -rt 0.1 <> <(:) || :
}
read_sleep
echo "p7-ok"
  • GNU bash 5.3.0: p7-ok, rc=0 (bare <> opens fd 0 read-write; <(:) feeds a process substitution into it as the redirect target)
  • rubash: p7.sh: line 3: syntax error near unexpected token <``, rc=2

Minimal shape: : <> <(:).

GNU anchor

parse.y redirection word grammar: a redirection operator with NO attached word followed by another redirection is accepted — the bare <> takes no filename and defaults (see parse.y redir() production / redir.c redir_open with NULL filename → r->filename NULL is legal for <>); the next <( is then lexed as a process substitution word via parse.y $(:-handling in read_token_word. If this needs a tighter citation, grep parse.y for the redirection production accepting an empty word.

Impact

pbb read_sleep idiom unparseable; any script using the fd-scrambling <> <(:) self-pipe trick (also used in timer loops) fails at parse time.

Activity

  1. added
    bug
    gnu-baseline
    on Sep 29, 2026
  2. caomengxuan666 commented on Sep 29, 2026

    @caomengxuan666
    MemberAuthor

    C anchor refinement: parse.y:602 LESS_GREATER WORD production requires a word; the following <(:) is lexed as that WORD because read_token()'s case '<': (parse.y:3692) falls through to word reading when the peek is (, and read_token_word()'s <( path builds the process substitution inside the word. So GNU grammar = LESS_GREATER followed by a procsub-bearing word; rubash's lexer treats the second < as a new redirection operator.

  3. added a commit that references this issue on Sep 29, 2026
  4. caomengxuan666 commented on Sep 29, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by wt14/pbbfix (9930e6c, master): assign_redirect_out_target only accepted the >(... output substitution form; <> <(:) fell into missing_redirect_target. LESS_GREATER WORD (parse.y:614-619) + token-initial <( is a process substitution. Repro/write/N=0-target/<> <(echo x)/exec 3<>/classic < <(...) all byte-identical. Known RUNTIME residual (recorded, not parse): GNU <> holds the pipe write end in O_RDWR so read waits for full close (rc 142 timeout); our text-transport model EOFs at byte exhaustion (rc 1) - the || : idiom is observably identical; the timeout shape is FUNCTION_STDIN-model follow-up.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggnu-baseline

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions