Skip to content

swiftly-install.sh Handle paths containing spaces #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions install/swiftly-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ read_yn_input () {
# the string "$HOME". This is used when printing to stdout.
# e.g. "home/user/.local/bin" => "$HOME/.local/bin"
replace_home_path () {
if [[ "$1" =~ ^"$HOME"(/|$) ]]; then
echo "\$HOME${1#$HOME}"
if [[ "$@" =~ ^"$HOME"(.*|$) ]]; then
echo "\$HOME${BASH_REMATCH[1]}"
else
echo "$1"
echo "$@"
fi
}

Expand All @@ -111,7 +111,7 @@ expand_home_path () {

# Prints the provided argument using the terminal's bold text effect.
bold () {
echo "$(tput bold)$1$(tput sgr0)"
echo "$(tput bold)$@$(tput sgr0)"
}

# Fetch the list of required system dependencies from the apple/swift-docker
Expand Down Expand Up @@ -636,7 +636,7 @@ end
EOF
)
ENV_FILE="env.fish"
SOURCE_LINE="source $(replace_home_path $HOME_DIR)/$ENV_FILE"
SOURCE_LINE='source "'$(replace_home_path $HOME_DIR)'/'$ENV_FILE'"'
;;
*)
ENV_OUT=$(cat <<EOF
Expand All @@ -648,7 +648,7 @@ fi
EOF
)
ENV_FILE="env.sh"
SOURCE_LINE=". $(replace_home_path $HOME_DIR)/$ENV_FILE"
SOURCE_LINE='. "'$(replace_home_path $HOME_DIR)'/'$ENV_FILE'"'
;;
esac

Expand Down