From fadf44e49f0abde3927e2679969f23eda96c43d5 Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch>
Date: Thu, 20 Feb 2025 11:11:50 +0100
Subject: [PATCH] update quoting in dirname, basename

---
 about                                           | 2 +-
 check_apache_requests                           | 2 +-
 check_ceph_diskfree                             | 5 +++--
 check_ceph_io                                   | 2 +-
 check_ceph_osd                                  | 2 +-
 check_ceph_status                               | 2 +-
 check_clientbackup                              | 2 +-
 check_couchdb                                   | 2 +-
 check_cpu                                       | 6 ++++--
 check_cronstatus                                | 5 +++--
 check_deployment                                | 2 +-
 check_disk-io                                   | 2 +-
 check_dns_responsetime                          | 2 +-
 check_docker_info                               | 2 +-
 check_docker_io                                 | 2 +-
 check_docker_stats                              | 2 +-
 check_dockercontainer_info                      | 2 +-
 check_dockercontainer_top                       | 2 +-
 check_eol                                       | 2 +-
 check_file_age                                  | 2 +-
 check_fs_errors                                 | 2 +-
 check_fs_writable                               | 4 ++--
 check_gitlab_tokens                             | 2 +-
 check_haproxy_health                            | 2 +-
 check_haproxy_status                            | 2 +-
 check_http                                      | 2 +-
 check_iml_backup_server                         | 2 +-
 check_journallog                                | 2 +-
 check_memory                                    | 8 +++++---
 check_mysqlserver                               | 4 ++--
 check_netio                                     | 2 +-
 check_netstat                                   | 2 +-
 check_onehost                                   | 2 +-
 check_onevm                                     | 2 +-
 check_opencpu                                   | 2 +-
 check_packages2install                          | 7 +++----
 check_php-fpm-status                            | 2 +-
 check_proc_mem                                  | 2 +-
 check_psqlserver                                | 4 ++--
 check_smartstatus                               | 8 ++++----
 check_snmp_data                                 | 4 ++--
 check_snmp_printer                              | 4 ++--
 check_snmp_synology                             | 2 +-
 check_ssl                                       | 2 +-
 check_ssl_certs                                 | 9 +++++----
 check_systemdservices                           | 8 ++++----
 check_systemdunit                               | 2 +-
 check_timesync                                  | 2 +-
 check_uptime                                    | 2 +-
 docs/30_Shared_functions/inc_pluginfunctions.md | 2 +-
 hello                                           | 2 +-
 inc_pluginfunctions                             | 8 ++++----
 52 files changed, 83 insertions(+), 77 deletions(-)

diff --git a/about b/about
index 93d0fb8..0bea24a 100755
--- a/about
+++ b/about
@@ -29,7 +29,7 @@ export self_APPVERSION=1.3
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_apache_requests b/check_apache_requests
index 6bed6cd..ce7b506 100755
--- a/check_apache_requests
+++ b/check_apache_requests
@@ -44,7 +44,7 @@ paramsWget="-T 5 -t 1 --no-check-certificate"
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_ceph_diskfree b/check_ceph_diskfree
index 3a3b72c..ec012bc 100755
--- a/check_ceph_diskfree
+++ b/check_ceph_diskfree
@@ -35,7 +35,7 @@ typeset -i iCritical=0
 
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
@@ -45,7 +45,8 @@ This check sends performance data.
 It uses 'ceph df' to parse data.
 
 SYNTAX:
-$(basename $0)
+
+    $_self
 
 OPTIONS:
     -h or --help   show this help.
diff --git a/check_ceph_io b/check_ceph_io
index 9dc4256..b0dc78e 100755
--- a/check_ceph_io
+++ b/check_ceph_io
@@ -29,7 +29,7 @@
 export self_APPVERSION=1.6
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_ceph_osd b/check_ceph_osd
index 7b60421..cac24b1 100755
--- a/check_ceph_osd
+++ b/check_ceph_osd
@@ -44,7 +44,7 @@ iColUpDown=5
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_ceph_status b/check_ceph_status
index 0e2e8c7..480b5be 100755
--- a/check_ceph_status
+++ b/check_ceph_status
@@ -47,7 +47,7 @@ line="__________________________________________________________________________
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_clientbackup b/check_clientbackup
index 834d04d..075be12 100755
--- a/check_clientbackup
+++ b/check_clientbackup
@@ -34,7 +34,7 @@ sInstalldir=/opt/imlbackup/client/
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_couchdb b/check_couchdb
index 02da514..d6fd7d9 100755
--- a/check_couchdb
+++ b/check_couchdb
@@ -41,7 +41,7 @@ NL="
 
 # show help
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_cpu b/check_cpu
index d5da20c..652935c 100755
--- a/check_cpu
+++ b/check_cpu
@@ -48,7 +48,8 @@ On higher cpu usage it can show processes that cause cpu waits and
 with most cpu consumption.
 
 SYNTAX:
-$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-i CRITICAL_IO_WAIT] [-p PROCESS_LIMIT]
+
+    $_self [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-i CRITICAL_IO_WAIT] [-p PROCESS_LIMIT]
 
 OPTIONS:
 
@@ -67,7 +68,8 @@ PARAMETERS:
     None.
 
 EXAMPLE:
-$(basename $0) -w 60 -c 80 -p 40
+
+    $_self -w 60 -c 80 -p 40
 
 EOF
 }
diff --git a/check_cronstatus b/check_cronstatus
index 86e56fb..2a1c63f 100755
--- a/check_cronstatus
+++ b/check_cronstatus
@@ -42,7 +42,7 @@ statusScript=/opt/cronwrapper/cronstatus.sh
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
@@ -55,7 +55,8 @@ The last run of each job is verified to these conditions:
 
 
 SYNTAX:
-$(basename $0) [-h] [SCRIPT]
+
+    $_self [-h] [SCRIPT]
 
 OPTIONS:
 
diff --git a/check_deployment b/check_deployment
index ff12d38..98c7ff5 100755
--- a/check_deployment
+++ b/check_deployment
@@ -20,7 +20,7 @@ sInstalldir=/opt/imldeployment-installer
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_disk-io b/check_disk-io
index f0de5ea..4e4c6cb 100755
--- a/check_disk-io
+++ b/check_disk-io
@@ -46,7 +46,7 @@ function getDisks(){
 
 # show help
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_dns_responsetime b/check_dns_responsetime
index c184b21..3194a19 100755
--- a/check_dns_responsetime
+++ b/check_dns_responsetime
@@ -39,7 +39,7 @@ typeset -i iNotReachable=0
 
 # show help
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_docker_info b/check_docker_info
index 46c6363..8f936a2 100755
--- a/check_docker_info
+++ b/check_docker_info
@@ -34,7 +34,7 @@ self_APPVERSION=1.6
 
 # show help
 function _showHelp(){
-    local _self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
     cat <<EOH
 $( ph.showImlHelpHeader )
 
diff --git a/check_docker_io b/check_docker_io
index a755fb9..a352515 100755
--- a/check_docker_io
+++ b/check_docker_io
@@ -32,7 +32,7 @@ typeset -i iSpeedTrans
 
 # show help
 function _showHelp(){
-    local _self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
     cat <<EOH
 $( ph.showImlHelpHeader )
 
diff --git a/check_docker_stats b/check_docker_stats
index 357900b..6e69f49 100755
--- a/check_docker_stats
+++ b/check_docker_stats
@@ -31,7 +31,7 @@ self_APPVERSION=1.2
 
 # show help
 function _showHelp(){
-    local _self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
     cat <<EOH
 $( ph.showImlHelpHeader )
 
diff --git a/check_dockercontainer_info b/check_dockercontainer_info
index 0ae798b..f5a8c00 100755
--- a/check_dockercontainer_info
+++ b/check_dockercontainer_info
@@ -29,7 +29,7 @@ self_APPVERSION=1.1
 
 # show help
 function _usage(){
-    local _self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
     cat <<EOH
 $( ph.showImlHelpHeader )
 
diff --git a/check_dockercontainer_top b/check_dockercontainer_top
index 39a3e29..7a22ed5 100755
--- a/check_dockercontainer_top
+++ b/check_dockercontainer_top
@@ -30,7 +30,7 @@ self_APPVERSION=1.2
 
 # show help
 function _showHelp(){
-    local _self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
     cat <<EOH
 $( ph.showImlHelpHeader )
 
diff --git a/check_eol b/check_eol
index 7b8f2ac..9e421f0 100755
--- a/check_eol
+++ b/check_eol
@@ -142,7 +142,7 @@ function findEolDate(){
 }
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_file_age b/check_file_age
index dca372a..27debf2 100755
--- a/check_file_age
+++ b/check_file_age
@@ -34,7 +34,7 @@ typeset -i iLimitCritical=14
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_fs_errors b/check_fs_errors
index 12e95c5..6ae65a7 100755
--- a/check_fs_errors
+++ b/check_fs_errors
@@ -26,7 +26,7 @@ export self_APPVERSION=1.4
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_fs_writable b/check_fs_writable
index c7cb842..58b3bb0 100755
--- a/check_fs_writable
+++ b/check_fs_writable
@@ -8,7 +8,7 @@
 #
 # ----------------------------------------------------------------------
 # 2021-03-23  v0.0  <axel.hahn@iml.unibe.ch>
-# 2023-07-27  v1.1  <axel.hahn@unibe.ch>     shell fixes; update help page
+# 2023-07-27  v1.1  <axel.hahn@unibe.ch>      shell fixes; update help page
 # 2025-02-10  v1.2  <axel.hahn@unibe.ch>      harden sourcing files
 # ======================================================================
 
@@ -25,7 +25,7 @@ out=""
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_gitlab_tokens b/check_gitlab_tokens
index 6e382c3..8366b19 100755
--- a/check_gitlab_tokens
+++ b/check_gitlab_tokens
@@ -54,7 +54,7 @@ output=""
 
 # Show help
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_haproxy_health b/check_haproxy_health
index 4621a41..a0d2398 100755
--- a/check_haproxy_health
+++ b/check_haproxy_health
@@ -29,7 +29,7 @@ tmpfile=/tmp/check_haproxy_healthcheck_$$
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_haproxy_status b/check_haproxy_status
index 5fa15d7..d7c9cd6 100755
--- a/check_haproxy_status
+++ b/check_haproxy_status
@@ -69,7 +69,7 @@ function checkStatus(){
 
 # show help
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_http b/check_http
index 8b88fb8..47cc9d5 100755
--- a/check_http
+++ b/check_http
@@ -22,7 +22,7 @@ export self_APPVERSION=1.1
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_iml_backup_server b/check_iml_backup_server
index db61e35..48c8cce 100755
--- a/check_iml_backup_server
+++ b/check_iml_backup_server
@@ -30,7 +30,7 @@ sMode=
 
 # show help
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
     cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_journallog b/check_journallog
index 04d2729..b73d76b 100755
--- a/check_journallog
+++ b/check_journallog
@@ -26,7 +26,7 @@ tmpfile=/tmp/last_journallog_line_${USER}.txt
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_memory b/check_memory
index f8f4928..e075494 100755
--- a/check_memory
+++ b/check_memory
@@ -48,7 +48,7 @@ function getMemvalue(){
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
@@ -59,7 +59,8 @@ be shown.
 This plugin sends performancedata.
 
 SYNTAX:
-$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h]
+
+    $_self [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-s SWAP_LIMIT] [-p PROCESS_LIMIT] [-h]
 
 OPTIONS:
     -w VALUE   Warning level for RAM usage [%]; default: 75
@@ -76,7 +77,8 @@ PARAMETERS:
     none
 
 EXAMPLE:
-$(basename $0) -w 90 -c 95 -p 70
+
+    $_self -w 90 -c 95 -p 70
 
 EOF
 }
diff --git a/check_mysqlserver b/check_mysqlserver
index 8a69975..d33f88e 100755
--- a/check_mysqlserver
+++ b/check_mysqlserver
@@ -105,7 +105,7 @@ EOF
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
@@ -240,7 +240,7 @@ fi
 
 # --- check installation
 if ! grep $myuser $cfgfile >/dev/null 2>&1; then
-    ph.abort "MYSQL access not possible yet. You need to install the monitoring user first: as root execute $(basename $0) -i"
+    ph.abort "MYSQL access not possible yet. You need to install the monitoring user first: as root execute $(basename "$0" ) -i"
 fi
 
 # ----------------------------------------------------------------------
diff --git a/check_netio b/check_netio
index 20134be..37eb4f0 100755
--- a/check_netio
+++ b/check_netio
@@ -36,7 +36,7 @@ nonPhysicalInterfaces="(lo|bond.*|cali.*|docker.*|flannel.*|ppp.*|veth.*):"
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_netstat b/check_netstat
index c1274c9..45c4405 100755
--- a/check_netstat
+++ b/check_netstat
@@ -23,7 +23,7 @@ export self_APPVERSION=1.3
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_onehost b/check_onehost
index b36af13..ba795fc 100755
--- a/check_onehost
+++ b/check_onehost
@@ -25,7 +25,7 @@ self_APPVERSION=1.5
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_onevm b/check_onevm
index d15fdcd..8cafccf 100755
--- a/check_onevm
+++ b/check_onevm
@@ -59,7 +59,7 @@ showData=0
 # ----------------------------------------------------------------------
 
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_opencpu b/check_opencpu
index ace024e..d36fb32 100755
--- a/check_opencpu
+++ b/check_opencpu
@@ -46,7 +46,7 @@ paramsWget="-T 5 -t 1 --no-check-certificate"
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_packages2install b/check_packages2install
index 2281f93..3c8551d 100755
--- a/check_packages2install
+++ b/check_packages2install
@@ -41,8 +41,8 @@ typeset -i iCount=0
 cronfile=/etc/cron.d/system-updater
 MYhost="localhost"
 
-dir_pkg="$( dirname $0 )/check_packages2install-pkgmanager"
-dir_filter="$( dirname $0 )/check_packages2install-data"
+dir_pkg="$( dirname "$0" )/check_packages2install-pkgmanager"
+dir_filter="$( dirname "$0" )/check_packages2install-data"
 
 # ----------------------------------------------------------------------
 # functions
@@ -84,8 +84,7 @@ function _functionExists(){
 
 # show help
 function showHelp(){
-    local _self
-    _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_php-fpm-status b/check_php-fpm-status
index c00576e..0903d17 100755
--- a/check_php-fpm-status
+++ b/check_php-fpm-status
@@ -71,7 +71,7 @@ function _getvalue(){
 
 
 function showHelp(){
-    local _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_proc_mem b/check_proc_mem
index 00b6212..4e11749 100755
--- a/check_proc_mem
+++ b/check_proc_mem
@@ -37,7 +37,7 @@ typeset -i iCountCritical=0
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_psqlserver b/check_psqlserver
index 3fa00e4..f44d163 100755
--- a/check_psqlserver
+++ b/check_psqlserver
@@ -49,7 +49,7 @@ function _queryFailed(){
     ph.setStatus "unknown"
     echo "UNKNOWN: the database query failed"
     echo "Quick troubleshooter:"
-    echo "* install a database user $myuser with command $(basename $0) -i"
+    echo "* install a database user $myuser with command $( basename "$0" ) -i"
     echo "* check pg_hba.conf login fails if it set to ident (eg. change it to md5)"
     ph.exit
 }
@@ -213,7 +213,7 @@ fi
 
 # --- check installation
 if ! grep $myuser $cfgfile >/dev/null 2>&1; then
-    ph.abort "PSQL access not possible yet. You need to install the monitoring user first: as root execute `basename $0` -i"
+    ph.abort "PSQL access not possible yet. You need to install the monitoring user first: as root execute $( basename "$0" ) -i"
 fi
 
 . "${cfgfile}"
diff --git a/check_smartstatus b/check_smartstatus
index 7af6668..cb19fa9 100755
--- a/check_smartstatus
+++ b/check_smartstatus
@@ -62,14 +62,14 @@ export PATH
 
 # show help
 function showHelp(){
-    local self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
     cat <<EOH
 $( ph.showImlHelpHeader )
 
 Show status of local S.M.A.R.T. devices.
 
 SYNTAX:
-    $self [-h] [-l] [devices]
+    $_self [-h] [-l] [devices]
 
 OPTIONS:
 
@@ -80,10 +80,10 @@ PARAMETERS:
 
 EXAMPLES
 
-    $self
+    $_self
       Scan all local disks
 
-    $self -l
+    $_self -l
       List all local disks without scanning them.
 
 EOH
diff --git a/check_snmp_data b/check_snmp_data
index f1ba7d0..33874a2 100755
--- a/check_snmp_data
+++ b/check_snmp_data
@@ -154,8 +154,8 @@ _isinteger(){
 #---------------------------------------------------
 # --- show usage
 function showHelp(){
-    _self=$( basename $0 )
-    local _methods=$(
+    local _self; _self="$( basename "$0" )"
+    local _methods; methods=$(
         _cfg_getMethods | while read -r line
         do
             METHOD=$(echo "$line" | cut -f 2 -d ":")
diff --git a/check_snmp_printer b/check_snmp_printer
index 3506a89..9a178df 100755
--- a/check_snmp_printer
+++ b/check_snmp_printer
@@ -21,7 +21,7 @@
 
 # shellcheck source=/dev/null
 . "$( dirname "$0" )/inc_pluginfunctions" || exit 1
-. "$( dirname $0 )/check_snmp_includes"   || exit 1
+. "$( dirname "$0" )/check_snmp_includes"   || exit 1
 
 self_APPVERSION=1.1
 
@@ -40,7 +40,7 @@ esac
 #---------------------------------------------------
 # --- show usage
 function showHelp(){
-    _self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
 cat <<EOH
 $( ph.showImlHelpHeader )
 
diff --git a/check_snmp_synology b/check_snmp_synology
index 23baeda..f5d92d4 100755
--- a/check_snmp_synology
+++ b/check_snmp_synology
@@ -72,7 +72,7 @@ FLAG_DISK=1
 FLAG_UPDATE=1
 FLAG_TEMPERATURE=1
 
-_self=$( basename $0 )
+_self="$( basename "$0" )"
 USAGE="$( ph.showImlHelpHeader )
 
 Check health of a Synology drive using SNMP.
diff --git a/check_ssl b/check_ssl
index f162278..b408c36 100755
--- a/check_ssl
+++ b/check_ssl
@@ -41,7 +41,7 @@ sStatus=
 
 # show help with syntax
 function showHelp(){
-    _self=$( basename $0 )
+    local _self; _self="$( basename "$0" )"
 cat <<EOH
 $( ph.showImlHelpHeader )
 
diff --git a/check_ssl_certs b/check_ssl_certs
index 4b2197c..a10f080 100755
--- a/check_ssl_certs
+++ b/check_ssl_certs
@@ -43,7 +43,7 @@ myDomain=".iml.unibe.ch"
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
@@ -51,7 +51,8 @@ Check locally installed SSL client certificates and warn if the
 expiration date comes closer. 
 
 SYNTAX:
-$(basename $0) [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-f "FILELIST"]
+
+    $_self [-w WARN_LIMIT] [-c CRITICAL_LIMIT] [-f "FILELIST"]
 
 OPTIONS:
 
@@ -70,11 +71,11 @@ PARAMETERS:
 
 EXAMPLE:
 
-    $(basename $0) -f "/etc/ssl/certs/*example.com.*.cer /somewhere/else/*.cer"
+    $_self -f "/etc/ssl/certs/*example.com.*.cer /somewhere/else/*.cer"
         Set 2 folders where to find the client certificates.
         They are seperated by space and both use * for globbing
 
-    $(basename $0) -w 30 -c 3 
+    $_self -w 30 -c 3 
         Overide the warning and critical level.
 
 EOF
diff --git a/check_systemdservices b/check_systemdservices
index 6acd6e9..4a7deed 100755
--- a/check_systemdservices
+++ b/check_systemdservices
@@ -31,10 +31,10 @@ self_APPVERSION=1.5
 cfgfile="$0.cfg"
 ignorefile="$0.ignore"
 
-tmpServices=/tmp/`basename $0`-services.txt
-tmpErrors=/tmp/`basename $0`-errors.txt
-tmpOut=/tmp/`basename $0`-out.txt
-tmpOutOther=/tmp/`basename $0`-out-other.txt
+tmpServices="/tmp/$( basename "$0" )-services.txt"
+tmpErrors=/tmp/$( basename "$0" )-errors.txt
+tmpOut=/tmp/$( basename "$0" )-out.txt
+tmpOutOther=/tmp/$( basename "$0" )-out-other.txt
 
 typeset -i iErrors=0
 typeset -i iOk=0
diff --git a/check_systemdunit b/check_systemdunit
index 8a57587..9dd9971 100755
--- a/check_systemdunit
+++ b/check_systemdunit
@@ -26,7 +26,7 @@ export self_APPVERSION=1.8
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_timesync b/check_timesync
index cdef18f..4a2ffe7 100755
--- a/check_timesync
+++ b/check_timesync
@@ -33,7 +33,7 @@ tmpfile=/tmp/check_timesync.tmp
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/check_uptime b/check_uptime
index 9442f2c..4a7d851 100755
--- a/check_uptime
+++ b/check_uptime
@@ -35,7 +35,7 @@ self_APPVERSION=1.6
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/docs/30_Shared_functions/inc_pluginfunctions.md b/docs/30_Shared_functions/inc_pluginfunctions.md
index d504796..7ccfc50 100644
--- a/docs/30_Shared_functions/inc_pluginfunctions.md
+++ b/docs/30_Shared_functions/inc_pluginfunctions.md
@@ -3,7 +3,7 @@
 All scripts start with sourcing a shared bash file
 
 ```shell
-. $( dirname $0 )/inc_pluginfunctions
+. "$( dirname "$0" )/inc_pluginfunctions" || exit 1
 ```
 
 In that script are several functions starting with prefix **ph.** (=plugin helper)
diff --git a/hello b/hello
index df48986..78a5efb 100755
--- a/hello
+++ b/hello
@@ -18,7 +18,7 @@ self_APPVERSION=1.1
 
 # show help text
 function showHelp(){
-    local _self; _self=$(basename $0)
+    local _self; _self="$( basename "$0" )"
 cat <<EOF
 $( ph.showImlHelpHeader )
 
diff --git a/inc_pluginfunctions b/inc_pluginfunctions
index bd10286..528fc7c 100644
--- a/inc_pluginfunctions
+++ b/inc_pluginfunctions
@@ -373,7 +373,7 @@ function ph._getStorefile(){
         local mydir="/tmp/icinga_counter_${USER}"
         test -n "$dir_data" && mydir="${dir_data}/_counter_${USER}"
         local _basename
-        _basename=$(basename $0)
+        _basename="$( basename "$0" )"
 
         test -d "${mydir}" || mkdir -p "${mydir}"
         echo "${mydir}/${_basename}${varName}.lastvalue"
@@ -417,7 +417,7 @@ function ph._readlastvalue(){
 # it creates a filename based on the started check script
 function ph._perfinit(){
   local _basename
-  _basename=$(basename $0)
+  _basename="$( basename "$0" )"
   ph_perfdatafile="/tmp/perfdata_$(echo $_basename | sed "s#[^a-z0-9\-]#_#g")"
   rm -f "${ph_perfdatafile}" 2>/dev/null
 }
@@ -578,12 +578,12 @@ function ph.execIfReady(){
 # including a link to the online help
 ph.showImlHelpHeader(){
   local _html;
-  _html=$(basename $0)
+  _html="$( basename "$0" )"
   _html=${_html//\-/_}.html
   cat <<EOF
 ______________________________________________________________________
 
-$( basename $0 | tr [:lower:] [:upper:] )
+$( basename "$0" | tr [:lower:] [:upper:] )
 v$self_APPVERSION
 
 (c) Institute for Medical Education - University of Bern
-- 
GitLab