#!/bin/bash # # Generic wrapper for bash functions so they can be invoked by external tools. # If the wrapper filename (or symlink) ends in 'w' then this is stripped and # the function is invoked with the --wait option before any command line ones. # # The function definition must be in a file in /etc/profile.d/ of the form # *.CMD.sh when CMD is the symlink filename without any trailing 'w' character. # # $Id: npp 222 2020-03-24 15:13:00Z SamEdge $ # set -u set -e set -o pipefail wait= declare cmdname="$0" cmdname="${cmdname##*/}" if [[ "${cmdname: -1}" == 'w' ]] ; then cmdname="${cmdname::-1}" wait="--wait" fi . /etc/profile.d/*."$cmdname".sh declare -r -i argcount="${#@}" if (( argcount != 0 )) ; then "$cmdname" $wait "$@" else "$cmdname" $wait fi