Skip to content

Commit

Permalink
Avoid applying shlex.join when not necessary
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <[email protected]>
  • Loading branch information
smarr committed Jan 27, 2025
1 parent 0ccbd81 commit 8e60dd7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rebench/model/run_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,15 +313,21 @@ def cmdline(self):
return self._construct_cmdline()

def _expand_user(self, possible_path):
something_changed = False

# split will change the type of quotes, which may cause issues with shell variables
parts = shlex.split(possible_path)
for i, part in enumerate(parts):
expanded = os.path.expanduser(part)
if "~" in expanded and ":" in expanded:
path_list = expanded.split(":")
expanded = ":".join([os.path.expanduser(p) for p in path_list])
parts[i] = expanded
return shlex.join(parts)
if parts[i] != expanded:
something_changed = True
parts[i] = expanded
if something_changed:
return shlex.join(parts)
return possible_path

def cmdline_for_next_invocation(self):
"""Replace the invocation number in the command line"""
Expand Down

0 comments on commit 8e60dd7

Please sign in to comment.