-_webi_enable_exec() {
- if [ -n "$(command -v spctl)" ]; then
- echo "Checking permission to execute '$pkg_cmd_name' on macOS 11+"
- set +e
- is_allowed="$(spctl -a "$pkg_src_cmd" 2>&1 | grep valid)"
- set -e
- if [ -z "$is_allowed" ]; then
- echo ""
- echo "##########################################"
- echo "# IMPORTANT: Permission Grant Required #"
- echo "##########################################"
- echo ""
- echo "Requesting permission to execute '$pkg_cmd_name' on macOS 10.14+"
- echo ""
- sleep 3
- spctl --add "$pkg_src_cmd"
+ export PATH="$my_path"
+
+ # in case pathman was recently installed and the PATH not updated
+ mkdir -p "$_webi_tmp"
+ # prevent "too few arguments" output on bash when there are 0 lines of stdout
+ "$HOME/.local/bin/pathman" add "$1" | grep "export" 2> /dev/null >> "$_webi_tmp/.PATH.env" || true
+ }
+
+ # group common pre-install tasks as default
+ webi_pre_install() {
+ webi_check
+ webi_download
+ webi_extract
+ }
+
+ # move commands from the extracted archive directory to $HOME/.local/opt or $HOME/.local/bin
+ # shellcheck disable=2120
+ # webi_install may be sourced and used elsewhere
+ webi_install() {
+ if [ -n "$WEBI_SINGLE" ] || [ "single" == "${1:-}" ]; then
+ mkdir -p "$(dirname "$pkg_src_cmd")"
+ mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
+ else
+ rm -rf "$pkg_src"
+ mv ./"$pkg_cmd_name"* "$pkg_src"
+ fi
+ }
+
+ # run post-install functions - just updating PATH by default
+ webi_post_install() {
+ webi_path_add "$(dirname "$pkg_dst_cmd")"
+ }
+
+ _webi_enable_exec() {
+ if [ -n "$(command -v spctl)" ] && [ -n "$(command -v xattr)" ]; then
+ # note: some packages contain files that cannot be affected by xattr
+ xattr -r -d com.apple.quarantine "$pkg_src" || true
+ return 0
+ fi
+ # TODO need to test that the above actually worked
+ # (and proceed to this below if it did not)
+ if [ -n "$(command -v spctl)" ]; then
+ echo "Checking permission to execute '$pkg_cmd_name' on macOS 11+"
+ set +e
+ is_allowed="$(spctl -a "$pkg_src_cmd" 2>&1 | grep valid)"
+ set -e
+ if [ -z "$is_allowed" ]; then
+ echo ""
+ echo "##########################################"
+ echo "# IMPORTANT: Permission Grant Required #"
+ echo "##########################################"
+ echo ""
+ echo "Requesting permission to execute '$pkg_cmd_name' on macOS 10.14+"
+ echo ""
+ sleep 3
+ spctl --add "$pkg_src_cmd"
+ fi