VERSION="0.2.1"
+# shellcheck disable=SC2034
STD_SHORT_OPTIONS="sdvhV"
+# shellcheck disable=SC2034
STD_LONG_OPTIONS="simulate,debug,verbose,nocolor,help,version"
+# shellcheck disable=SC2034
STD_USAGE_MSG=$( cat <<-EOF
-s|--simulate Simulation mode - dont apply any changes.
-d|--debug Debug output (bash -x).
# Standard global variables
VERBOSE="n"
DEBUG="n"
+# shellcheck disable=SC2034
DO_ASK="n"
SIMULATE="n"
declare -a REMAINING_ARGS=()
declare -a REMAINING_OPTS=()
+# shellcheck disable=SC2034
NFS_HOMEDIR_PARENT='/mnt/nfs/home'
DESCRIPTION="${DESCRIPTION:-Failing script description}"
LDAP_HOST="ldap.pixelpark.com"
LDAP_PORT=389
+# shellcheck disable=SC2034
LDAP_STD_OPTS_SHORT="D:y:H:P:b:"
+# shellcheck disable=SC2034
LDAP_STD_OPTS_LONG="bind-dn:,password-file:,ldap-host:,ldap-port:,base-dn:"
+# shellcheck disable=SC2034
LDAP_USAGE_MSG=$( cat <<-EOF
-D|--bind-dn DN
Use this Distinguished Name DN to bind to the LDAP directory.
local term=
if [[ -f ~/.dir_colors ]] ; then
- match_lhs="${match_lhs}$( cat ~/.dir_colors | grep '^TERM ' | sed -e 's/^TERM *//' -e 's/ .*//')"
+ match_lhs="${match_lhs}$( grep '^TERM ' ~/.dir_colors | sed -e 's/^TERM *//' -e 's/ .*//')"
fi
if [[ -f /etc/DIR_COLORS ]] ; then
- match_lhs="${match_lhs}$( cat /etc/DIR_COLORS | grep '^TERM ' | sed -e 's/^TERM *//' -e 's/ .*//')"
+ match_lhs="${match_lhs}$( grep '^TERM ' /etc/DIR_COLORS | sed -e 's/^TERM *//' -e 's/ .*//')"
fi
if [[ -z ${match_lhs} ]] ; then
type -P dircolors >/dev/null && \
match_lhs=$(dircolors --print-database | grep '^TERM ' | sed -e 's/^TERM *//' -e 's/ .*//')
fi
for term in ${match_lhs} ; do
- if [[ "${safe_term}" == ${term} || "${TERM}" == ${term} ]] ; then
+ if [[ "${safe_term}" == "${term}" || "${TERM}" == "${term}" ]] ; then
use_color="true"
break
fi
RED="\033[38;5;196m"
YELLOW="\033[38;5;226m"
GREEN="\033[38;5;46m"
+ # shellcheck disable=SC2034
BLUE="\033[38;5;27m"
CYAN="\033[38;5;14m"
NORMAL="\033[39m"
RED=""
YELLOW=""
GREEN=""
+ # shellcheck disable=SC2034
BLUE=""
CYAN=""
NORMAL=""
fi
- local my_tty=$(tty)
+ local my_tty=
+ my_tty=$(tty)
if [[ "${my_tty}" =~ 'not a tty' ]] ; then
my_tty='-'
fi
if [[ "${my_tty}" = '-' || "${safe_term}" = "dump" ]] ; then
+ # shellcheck disable=SC2034
HAS_TTY='n'
fi
RED=""
YELLOW=""
GREEN=""
+ # shellcheck disable=SC2034
BLUE=""
CYAN=""
NORMAL=""
--) shift
break
;;
- *) REMAINING_OPTS+=($1)
+ *) REMAINING_OPTS+=( "$1" )
shift
;;
esac
if [[ "$#" -gt "0" ]] ; then
REMAINING_ARGS=("--")
while [[ "$#" -gt "0" ]] ; do
- REMAINING_ARGS+=($1)
+ REMAINING_ARGS+=( "$1" )
shift
done
fi
--) shift
break
;;
- *) REMAINING_OPTS+=($1)
+ *) REMAINING_OPTS+=( "$1" )
shift
;;
esac
if [[ "$#" -gt "0" ]] ; then
REMAINING_ARGS=("--")
while [[ "$#" -gt "0" ]] ; do
- REMAINING_ARGS+=($1)
+ REMAINING_ARGS+=( "$1" )
shift
done
fi
if [[ "${VERBOSE}" != "y" ]] ; then
return 0
fi
- echo -e " * [$(my_date)] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $@" >&2
+ echo -e " * [$(my_date)] [${BASE_NAME}:${CYAN}DEBUG${NORMAL}]: $*" >&2
}
#------------------------------------------------------------------------------
info() {
- echo -e " ${GREEN}*${NORMAL} [$(my_date)] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $@" >&2
+ echo -e " ${GREEN}*${NORMAL} [$(my_date)] [${BASE_NAME}:${GREEN}INFO${NORMAL}] : $*" >&2
}
#------------------------------------------------------------------------------
warn() {
- echo -e " ${YELLOW}*${NORMAL} [$(my_date)] [${BASE_NAME}:${YELLOW}WARN${NORMAL}] : $@" >&2
+ echo -e " ${YELLOW}*${NORMAL} [$(my_date)] [${BASE_NAME}:${YELLOW}WARN${NORMAL}] : $*" >&2
}
#------------------------------------------------------------------------------
error() {
- echo -e " ${RED}*${NORMAL} [$(my_date)] [${BASE_NAME}:${RED}ERROR${NORMAL}]: $@" >&2
+ echo -e " ${RED}*${NORMAL} [$(my_date)] [${BASE_NAME}:${RED}ERROR${NORMAL}]: $*" >&2
}
#------------------------------------------------------------------------------
LC_COLLATE="${new_locale}"
LC_MONETARY="${new_locale}"
LC_MESSAGES="${new_locale}"
+ # shellcheck disable=SC2034
LC_PAPER="${new_locale}"
+ # shellcheck disable=SC2034
LC_NAME="${new_locale}"
+ # shellcheck disable=SC2034
LC_ADDRESS="${new_locale}"
+ # shellcheck disable=SC2034
LC_TELEPHONE="${new_locale}"
+ # shellcheck disable=SC2034
LC_MEASUREMENT="${new_locale}"
+ # shellcheck disable=SC2034
LC_IDENTIFICATION="${new_locale}"
fi