workarounds for fluter
[webi-installers/.git] / _webi / template.sh
index fc7629a27fec5bf2b4543f1614bd94d46e504975..6ca7bbfe73579537d1216dd29552bae0bada3485 100644 (file)
@@ -211,7 +211,8 @@ webi_path_add() {
 
     # in case pathman was recently installed and the PATH not updated
     mkdir -p "$_webi_tmp"
-    "$HOME/.local/bin/pathman" add "$1" | grep "export" >> "$_webi_tmp/.PATH.env" || true
+    # 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
@@ -226,7 +227,6 @@ webi_install() {
     if [ -n "$WEBI_SINGLE" ] || [ "single" == "${1:-}" ]; then
         mkdir -p "$(dirname $pkg_src_cmd)"
         mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
-        chmod a+x "$pkg_src_cmd"
     else
         rm -rf "$pkg_src"
         mv ./"$pkg_cmd_name"* "$pkg_src"
@@ -239,6 +239,13 @@ webi_post_install() {
 }
 
 _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
@@ -315,14 +322,16 @@ if [ -n "$(command -v pkg_get_current_version)" ]; then
     pushd "$WEBI_TMP" 2>&1 >/dev/null
         echo "Installing to $pkg_src_cmd"
         [ -n "$(command -v pkg_install)" ] && pkg_install || webi_install
+        chmod a+x "$pkg_src"
+        chmod a+x "$pkg_src_cmd"
     popd 2>&1 >/dev/null
 
     webi_link
 
+    _webi_enable_exec
     pushd "$WEBI_TMP" 2>&1 >/dev/null
         [ -n "$(command -v pkg_post_install)" ] && pkg_post_install || webi_post_install
     popd 2>&1 >/dev/null
-    _webi_enable_exec
 
     pushd "$WEBI_TMP" 2>&1 >/dev/null
         [ -n "$(command -v pkg_done_message)" ] && pkg_done_message || _webi_done_message