Repository navigation
loopguard: read a wrapper's own options before a shell edit - #237
Open
KVR Vishnu (VISHNU0906) wants to merge 1 commit into
Open
KVR Vishnu (VISHNU0906) wants to merge 1 commit into
KVR Vishnu (VISHNU0906) wants to merge 1 commit into
Conversation
`_bare` dropped only the name of sudo, env, time, nohup and command, so `env -u VAR sed -i ...` or `sudo -u bob sed -i ...` left the option as the command and the edit was not counted. timeout and nice were not dropped at all, so `timeout 60 sed -i ...` was missed too, and so was a `git checkout --` revert run through any of them. Skip each wrapper's options, with the ones that take a value (`sudo -u`, `env -u/-C`, `timeout -s/-k`, `nice -n`, `time -o/-f`), and timeout's duration. Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>
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.
Hi Saksham Uboweja (@SakshamUboweja), a follow-up to #212 and #213, this time in
_bareinloopguard/shell_edits.py._baredrops the wrapper in front of a command before the parser looks at it, but it only dropped the wrapper's name. If the wrapper had options of its own, the first option became the "command" and the edit was lost:env -u CURSOR_AGENT sed -i 's/a/b/' pkg/mod.pyandsudo -u bob sed -i ...were not counted as editstimeoutandnicewere not in the list at all, sotimeout 60 sed -i ...andnice -n 10 sed -i ...were missed too (the verification side already knows these from_PREFIX_REinturn.py)git apply,teeand agit checkout --revert run through any of themNow
_baregoes past each wrapper's options, including the ones that take a value (sudo -u/-g/-C/...,env -u/-C,timeout -s/-k,nice -n,time -o/-f), short clusters likesudo -Eu bob, attached values likenice -n5,--, and timeout's duration.VAR=1words between wrappers are still skipped. Plainsudo sed -i ...and the rest behave as before, and reads likeenv -u X sed -n '1,20p' f.pystill count as nothing.Tests: new cases in
test_edits_made_through_the_shell_are_recognised, plus one throughTurnGuard.foldthat checks two wrapped edits and asudo -u bob git checkout --revert all count. Withshell_edits.pyfrom main, 11 of them fail.python -m pytest tests experiments/testspasses on Python 3.10 and 3.13 (1407 passed, 20 skipped), andscripts/dead_code.pyoutput is the same as on main.