Repository navigation
fix: stop recursion through pipelines at the depth limit - #177
Open
ferdingler wants to merge 1 commit into
Open
ferdingler wants to merge 1 commit into
ferdingler wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Description
If a function calls itself as part of a pipeline, like
f() { f | cat; }; f, the shell runs until the timeout instead of stopping at the recursion limit. A function called directly counts toward the limit, and so do subshells and command substitutions, but a function running as one stage of a pipeline didn't.Now a function in a pipeline stage counts as one more level of depth, the same as a direct call, so this kind of recursion stops right away at the configured limit. Normal nested pipelines under the limit behave the same as before.
I added a regression test with a small depth limit. On main it ran until the timeout; with the change it stops after a few calls and finishes instantly. I also checked that two levels of functions through pipelines still work under the same limit. One thing I noticed but left alone: errors printed from inside a function that runs as a pipeline stage don't reach the caller's stderr, so the recursion error itself isn't visible there. That's a separate fix.
Related Issues
None
Documentation PR
None
Type of Change
Bug fix
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce new warnings.
cargo test --workspace --all-targets,pytest tests/python,npm test)cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.