Repository navigation
loopguard: read a sed or perl script given inside its option word - #179
Merged
Aaron Li (aaron-jx-li) merged 1 commit intoNov 10, 2026
Merged
Conversation
sed -i --expression='s/a/b/' f.py, sed -i -e's/a/b/' f.py, sed -i --file=x.sed f.py and perl -i -pe's/a/b/' f.py carry the script in the option word. The in-place parser only knew the forms where the script is the next word, so it took f.py for the script and the edit was never counted. 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 Aaron Li (@aaron-jx-li), another small one from the shell-edit parser in
loopguard/shell_edits.py._inplace_filesonly recognised a sed or perl script given as the next word (-e 's/a/b/',--file x.sed). When the script sits inside the option word, the parser took the file for the script and found no edit:sed -i --expression='s/a/b/' pkg/mod.pysed -i -e's/a/b/' pkg/mod.pysed -i --file=fix.sed pkg/mod.pyperl -i -pe's/a/b/' pkg/mod.pyAll four returned
[]fromshell_edit_targets, soTurnGuard.folddid not count the edit and the judge's digest showed no edit for that turn. Withsed --in-place --expression=s/a/b/ a.py b.py, onlyb.pywas counted.The script flag check now returns where the script is: the next word, or inside the option itself. Short option clusters are read letter by letter, so
-nestill means the next word is the script, and-i.bak,-Mre=evalor-Idirare not read as scripts.Tests: new cases in
test_edits_made_through_the_shell_are_recognisedplus one throughTurnGuard.fold. With the fix reverted, 6 of them fail; the other new cases (-ne,-i.orig -pe,-Mre=eval) are there to make sure those keep working.python -m pytest testspasses on Python 3.10, 3.12 and 3.13 (859 passed, 16 skipped),experiments/testspasses (393 passed), andscripts/dead_code.pyreports nothing new.This touches the same file as #176 but a different function, so the two don't conflict.