$OpenBSD: patch-etc_icinga2_scripts_mail-host-notification_sh,v 1.6 2018/11/16 13:01:04 martijn Exp $
Index: etc/icinga2/scripts/mail-host-notification.sh
--- etc/icinga2/scripts/mail-host-notification.sh.orig
+++ etc/icinga2/scripts/mail-host-notification.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/ksh
 #
 # Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/)
 # Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT license 
@@ -51,11 +51,15 @@ Error() {
 }
 
 urlencode() {
-  local LANG=C i c e=''
-  for ((i=0;i<${#1};i++)); do
-    c=${1:$i:1}
-    [[ "$c" =~ [a-zA-Z0-9\.\~\_\-] ]] || printf -v c '%%%02X' "'$c"
-    e+="$c"
+  local LANG=C i c e s="$1"
+  i=0
+  
+  while [ $i -lt ${#1} ]; do
+    [ "$i" -eq 0 ] || s="${s#?}"
+    c=${s%"${s#?}"}
+    [ -z "${c#[[:alnum:].~_-]}" ] || c=$(printf '%%%02X' "'$c")
+    e="${e}${c}"
+    i=$((i + 1))
   done
   echo "$e"
 }
