cryinkfly / Autodesk-Fusion-360-for-Linux

This is a project, where I give you a way to use Autodesk Fusion 360 on Linux!
https://github.com/cryinkfly/Fusion-360---Linux-Wine-Version-/wiki
MIT License
1.79k stars 115 forks source link

Install script cannot handle space in `$WP_DIRECTORY` #255

Closed mikkorantalainen closed 1 year ago

mikkorantalainen commented 1 year ago

The install script contains various parts that cannot handle spaces in variable $WP_DIRECTORY correctly.

For example:

echo "WP_BOX='$WP_DIRECTORY' . $SP_PATH/bin/launcher.sh" >> $WP_DIRECTORY/box-run.sh

will try to write to file or directory ending at the first space in the variable. In addition, if $WP_DIRECTORY contains single quote mark, then the remaining part after the first space of the $WP_DIRECTORY will be executed instead of launcher.sh as designed.

I think the best way to handle issues like this is to do something like this:

SHELL_ENCODED_WP_DIRECTORY="$(printf "%s" "$WP_DIRECTORY" | sed "s/'/'\x22'\x22'/")"
SHELL_ENCODED_SP_PATH="$(printf "%s" "$SP_PATH" | sed "s/'/'\x22'\x22'/")"
echo "WP_BOX='$SHELL_ENCODED_WP_DIRECTORY'" source '"'$SHELL_ENCODED_SP_PATH/bin/launcher.sh'"' >> "$WP_DIRECTORY/box-run.sh"

Similar tweaks would be needed for other parts that generate new shell scripts. Other parts can just use double quotes around the variables. I also used source instead of . above to make it more readable. You already have bash shebang so you might as well use more readable bash features.