Repository navigation
fix(procsub): accept { ...; } bodies on write-side >(...) substitution - #1315
Merged
Merged
Conversation
Two forms failed (rubash#1223):
1. `echo hello > >({ cat; })` died with `>({ cat; }): ambiguous
redirect`. Materialization rewrites redirect.target to the carrier
temp path but leaves the original `>({ cat; })` word in
target_metadata.raw; expand_redirect_operand_fields then fed that raw
into expand_braces_with_optional_raw, where `{ cat; }` reads as a
brace group and the whole raw word returned as the "expanded" operand
— whitespace -> ambiguity. GNU never field-splits that operand:
redir.c:298 redirection_expand -> expand_word_internal's '<'/'>' cases
(subst.c:11349-11378 extract_process_subst -> subst.c:6362
process_substitute) return the substitution filename as the single
field. expand_redirect_target now returns the materialized target
verbatim whenever the raw operand is a `>(`/`<(` word.
2. `echo hello | tee >({ cat; }) >/dev/null` left the external child a
literal /dev/fd/63 word it could not open. dev_fd_table_operand
returned None for FdWriteEndpoint::ProcessSubstitution; it now hands
the child the carrier's real path (the fd table entry already carries
it), matching GNU's dup of the procsub pipe write end.
Verified vs WSL GNU Bash 5.3.20 (script-file probes):
echo hello > >({ cat; }); echo done -> hello / done
echo hello > >( { cat; } ); echo done -> hello / done
echo hello | tee >({ cat; }) >/dev/null; done -> hello / done
Generated with [Devin](https://devin.ai)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1223
Two divergences fixed:
echo hello > >({ cat; })died with>({ cat; }): ambiguous redirect. Materialization rewritesredirect.targetto the carrier temp path but leaves the original word intarget_metadata.raw;expand_redirect_operand_fieldsthen fed that raw intoexpand_braces_with_optional_raw, where{ cat; }reads as a brace group and the whole raw word came back as the "expanded" operand — whitespace → ambiguity. GNU never field-splits that operand:redir.c:298 redirection_expand→expand_word_internal's'<'/'>'cases (subst.c:11349-11378 extract_process_subst→subst.c:6362 process_substitute) return the substitution filename as the single field.expand_redirect_targetnow returns the materialized target verbatim whenever the raw operand is a>(/<(word.echo hello | tee >({ cat; }) >/dev/nullleft the external child a literal/dev/fd/63word it could not open.dev_fd_table_operandreturnedNoneforFdWriteEndpoint::ProcessSubstitution; it now hands the child the carrier's real path (GNU redir.c: the fd is the write end of the procsub pipe).Before:
After (== GNU 5.3.20):
echo hello | tee >({ cat; }) >/dev/nullnow printshello(was:tee: /dev/fd/63: No such file or directory).Test plan
cargo test --test issue1223_procsub_brace_body— 3 tests greencargo fmt --checkcleanGenerated with Devin