Skip to content

Commit

Permalink
Fix winecmd when Wine path contains spaces
Browse files Browse the repository at this point in the history
Fix `winecmd` verb when path to Wine contains a space.

The arguments for `winetricks_shell` were passed as-is in a
space-separated string, meaning a single argument with a space in it
(eg. the Wine path) would break the entire command.

Fix this by single quoting each argument and concatenating them
together. This is a bit tricky in POSIX sh without `printf %q`,
but seems to work fine with the code suggested by ShellCheck for SC3050.
  • Loading branch information
Matoking authored and austin987 committed Sep 3, 2023
1 parent 8d54be5 commit 9ad2f41
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/winetricks
Original file line number Diff line number Diff line change
Expand Up @@ -19221,6 +19221,8 @@ winetricks_stats_log_command()
winetricks_shell()
{
(
_W_escape() { printf "'%s'\\n" "$(printf '%s' "$1" | sed -e "s/'/'\\\\''/g")"; }

w_try_cd "${W_DRIVE_C}"
export WINE

Expand All @@ -19232,7 +19234,14 @@ winetricks_shell()
for term in gnome-terminal konsole Terminal xterm; do
if test "$(command -v ${term} 2>/dev/null)"; then
if [ -n "${*}" ]; then
WINEDEBUG=-all ${term} -e "${*}"
# Convert the list of arguments into a single
# string while single quoting each argument.
_W_args=""
for arg in "$@"; do
_W_args="${_W_args}$(_W_escape "${arg}") "
done

WINEDEBUG=-all ${term} -e "${_W_args}"
else
WINEDEBUG=-all ${term}
fi
Expand Down

0 comments on commit 9ad2f41

Please sign in to comment.