Skip to content

Commit

Permalink
Use more robust check for sed version.
Browse files Browse the repository at this point in the history
Generally, macOS uses BSD sed and Linux uses GNU sed. However, in some circumstances (CI macOS arm64) it appears that macOS may be using GNU instead of BSD. Therefore it is best to check sed directly for BSD/GNU rather than using the platform as a proxy.

Remove patch for old-style markers.
  • Loading branch information
mrclary committed Dec 30, 2023
1 parent fba6716 commit c597378
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions installers-conda/resources/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ spy_exe=${PREFIX}/envs/spyder-runtime/bin/spyder
u_spy_exe=${PREFIX}/uninstall-spyder.sh
all_user=$([[ -e ${PREFIX}/.nonadmin ]] && echo false || echo true)

sed_opts=("-i")
alias_text="alias uninstall-spyder=${u_spy_exe}"
if [[ "$OSTYPE" = "darwin"* ]]; then
sed_opts+=("", "-e")
shortcut_path="/Applications/${INSTALLER_NAME}.app"
if [[ "$all_user" = "false" ]]; then
shortcut_path="${HOME}${shortcut_path}"
Expand All @@ -36,6 +34,16 @@ else
fi
fi


# BSD sed requires extra "" after -i flag
if [[ $(sed --version 2>/dev/null) ]]; then
# GNU sed has --version
sed_opts=("-i" "-e")
else
# BSD sed does not have --version
sed_opts=("-i" "" "-e")
fi

m1="# >>> Added by Spyder >>>"
m2="# <<< Added by Spyder <<<"

Expand All @@ -45,12 +53,7 @@ add_alias() {
exit 0
fi

# Remove old-style markers, if present; discard after EXPERIMENTAL
# installer attrition.
sed ${sed_opts[@]} "/# <<<< Added by Spyder <<<</,/# >>>> Added by Spyder >>>>/d" $shell_init

# Posix compliant sed does not like semicolons.
# Must use newlines to work on macOS
# BSD sed does not like semicolons; newlines work for both BSD and GNU.
sed ${sed_opts[@]} "
/$m1/,/$m2/{
h
Expand Down

0 comments on commit c597378

Please sign in to comment.