diff --git a/markdownrunner.py b/markdownrunner.py index 8f040ee..1a8a114 100755 --- a/markdownrunner.py +++ b/markdownrunner.py @@ -74,13 +74,13 @@ def parse_snippet(s: Tuple[str, str]) -> Sequence[Command]: directory = parts[1] continue elif line.startswith('sudo -u'): - parts = line.split(maxsplit=5) + parts = line.split(maxsplit=4) assert parts[3] == '-H', "Insecure sudo?" user = parts[2] directory = f'~{user}' # This actually works with SSH. That is nice, since we don't need to know the target's /etc/passwd cmd = parts[4] elif line.startswith('sudo'): - parts = line.split(maxsplit=2) + parts = line.split(maxsplit=1) assert not parts[1].startswith('-'), "Weird sudo" user = 'root' cmd = parts[1] @@ -141,7 +141,7 @@ def user_action(hunk: Sequence[Command], context=None) -> Sequence[Command]: # Read the file back new_hunk = [] for line in tmpfile.file.readlines(): - parts = line.split('\t', maxsplit=3) + parts = line.split('\t', maxsplit=2) new_hunk.append(Command(user=parts[0],directory=parts[1],command=parts[2],context=None)) # Python has no goto for restarting, but we can recurse return user_action(new_hunk, context)