check argv length before indexing (fixes #2411)#2442
Merged
andychu merged 2 commits intosoil-stagingfrom Oct 4, 2025
Merged
Conversation
We have a helper to check if prefix bindings should pe preserved when running a simple command. This check requires checking the first argument of the command line, but doesn't check the length before indexing. This commit patches the helper to return early if argv is empty. From there, the usual command execution logic will take care of the rest: either a noop, or erroring out if strict_argv is enabled.
b88a55a to
f147088
Compare
andychu
reviewed
Sep 30, 2025
Contributor
andychu
left a comment
There was a problem hiding this comment.
Thanks, I'm glad this was a localized fix!
| elif case(cmd_value_e.Argv): | ||
| cmd_val = cast(cmd_value.Argv, UP_cmd_val) | ||
| if len(cmd_val.argv) == 0: | ||
| return True |
Contributor
There was a problem hiding this comment.
Hm it's somewhat surprising to me that the binding persists - I was thinking it should be return False !!!
$ bash -c 'FOO=bar $undef; echo FOO=$FOO'
FOO=bar
$ bash -c 'FOO=bar echo; echo FOO=$FOO' # does NOT persist
FOO=
I would have thought FOO=bar goes out of scope in the first case, like the second
It looks like the spec test covers it, but how about adding a comment about this behavior?
Contributor
|
Great thanks! |
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.
We have a helper to check if prefix bindings should pe preserved when running a simple command. This check requires checking the first argument of the command line, but doesn't check the length before indexing. This commit patches the helper to return early if argv is empty. From there, the usual command execution logic will take care of the rest: either a noop, or erroring out if strict_argv is enabled.