Skip to content

Commit ae5c950

Browse files
sourcehawkclaude
andcommitted
fix(skills/bounding-heavy-commands): keep the directory of a held command on one line
A path name can hold a line break, so a held line of the check could split in two, and the second part could read as a line of its own. The directory now gets the same whitespace folding as the command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 48d4905 commit ae5c950

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎skills/bounding-heavy-commands/scripts/bounded_run.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,8 @@ def mib(text: Optional[str]) -> str:
797797
working = os.readlink(os.path.join(proc_root, str(pid), "cwd")) if pid is not None else None
798798
except OSError:
799799
working = None
800+
if working is not None:
801+
working = " ".join(working.split())
800802
command = _held_command(pid, proc_root) if pid is not None else None
801803
held.append("unit=%s budget=%s used=%s age=%s dir=%s command=%s" % (
802804
name[:-len(".scope")], mib(limit), mib(current), "-" if age is None else "%ds" % age,

‎skills/bounding-heavy-commands/scripts/tests/test_bounded_run.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,11 @@ def test_a_long_command_is_cut_and_stays_on_one_line(self):
10991099
self.assertEqual(len(command), bounded_run.HELD_COMMAND_CHARACTERS)
11001100
self.assertTrue(command.startswith("sh -c first second x"), command)
11011101

1102+
def test_a_directory_with_a_line_break_stays_on_one_line(self):
1103+
self.scope("bounded-run-100-aaaaaa.scope")
1104+
self.process(100, self.inside("tool"), cwd="/work/two\nlines")
1105+
self.assertEqual(self.held(), ["unit=bounded-run-100-aaaaaa budget=4096M used=1024M age=120s dir=/work/two lines command=tool"])
1106+
11021107
def test_a_command_without_the_prefix_of_the_wrapper_is_given_whole(self):
11031108
self.scope("bounded-run-100-aaaaaa.scope")
11041109
self.process(100, ["sleep", "60"])

0 commit comments

Comments
 (0)