Skip to content

Commit

Permalink
CLI Launch: Shlex executable path
Browse files Browse the repository at this point in the history
If an executable path has a single quote (') in it, it can now be launched.

Fix protontricks-launch tests

`shlex.quote` usage means that single quotes are no longer added
unnecessarily to the executable path.

Co-authored-by: Janne Pulkkinen <janne.pulkkinen@protonmail.com>
  • Loading branch information
grant-h and Matoking committed Jan 18, 2024
1 parent 8076c02 commit 4852aae
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/protontricks/cli/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def exit_(error):
cli_args += ["--no-term"]

inner_args = " ".join(
["wine", f"'{executable_path}'"]
["wine", shlex.quote(str(executable_path))]
+ exec_args
)

Expand Down
6 changes: 3 additions & 3 deletions tests/cli/test_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_run_executable(
# 'test.exe' was executed
command = commands[-1]
assert command.args.startswith("wine ")
assert command.args.endswith("/test.exe'")
assert command.args.endswith("/test.exe")

assert command.env["WINEPREFIX"] == str(steam_app.prefix_path)

Expand All @@ -45,7 +45,7 @@ def test_run_executable_appid(
# 'test.exe' was executed
command = commands[-1]
assert command.args.startswith("wine ")
assert command.args.endswith("/test.exe'")
assert command.args.endswith("/test.exe")

assert command.env["WINEPREFIX"] == str(steam_app.prefix_path)

Expand Down Expand Up @@ -123,7 +123,7 @@ def _set_launch_args(*args, **kwargs):
"--no-background-wineserver", "--no-term", "-c"
]
assert cli_args[6].startswith("wine ")
assert cli_args[6].endswith("test.exe'")
assert cli_args[6].endswith("test.exe")
assert cli_args[7] == "10"

# Steam installation was provided to the main entrypoint
Expand Down

0 comments on commit 4852aae

Please sign in to comment.