Skip to content

Commit

Permalink
Use printf instead of echo just in case run paths contain hyphens
Browse files Browse the repository at this point in the history
  • Loading branch information
manicmaniac committed May 18, 2023
1 parent 555ef2d commit 96af4e4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Package/Scripts/preinstall
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ get_rpaths() {
developer_dir="$(/usr/bin/xcode-select --print-path)"
if ! is_developer_dir_in_xcode "$developer_dir"; then
# shellcheck disable=SC2016
echo 'error: DEVELOPER_DIR is not in Xcode. Run `xcode-select --switch /path/to/Xcode.app/Contents/Developer` to set it to the correct path.' >&2
/usr/bin/printf 'error: DEVELOPER_DIR is not in Xcode. Run `xcode-select --switch /path/to/Xcode.app/Contents/Developer` to set it to the correct path.\n' >&2
exit 1
fi

if [ -z "$INSTALLER_PAYLOAD_DIR" ]; then
echo 'error: INSTALLER_PAYLOAD_DIR is not set. Do not run this script outside of installer context.' >&2
/usr/bin/printf 'error: INSTALLER_PAYLOAD_DIR is not set. Do not run this script outside of installer context.\n' >&2
exit 1
fi

IFS='
' # newline
for old_rpath in $(get_rpaths "${INSTALLER_PAYLOAD_DIR}/usr/local/bin/xcnew")
do
new_rpath="$(echo "$old_rpath" | /usr/bin/awk -v developer_dir="$developer_dir" '{sub(".*/Contents/Developer", developer_dir); print}')"
new_rpath="$(/usr/bin/printf "%s\n" "$old_rpath" | /usr/bin/awk -v developer_dir="$developer_dir" '{sub(".*/Contents/Developer", developer_dir); print}')"
/usr/bin/install_name_tool -rpath "$old_rpath" "$new_rpath" "${INSTALLER_PAYLOAD_DIR}/usr/local/bin/xcnew"
done

0 comments on commit 96af4e4

Please sign in to comment.