DEBUG="n"
QUIET='n'
-VERSION="2.1"
+VERSION="2.2"
# console colors:
RED=""
YELLOW=""
GREEN=""
-BLUE=""
+# BLUE=""
CYAN=""
NORMAL=""
-HAS_TTY='y'
-
-BASENAME="$(basename ${0})"
-BASE_DIR=$( dirname $( dirname $0 ) )
-cd ${BASE_DIR}
+BASENAME=$(basename "${0}" )
+BASE_DIR=$( dirname "$( dirname "$0" )" )
+cd "${BASE_DIR}"
BASE_DIR=$( readlink -f . )
PIP_OPTIONS=
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
+ # shellcheck disable=SC2053
if [[ "${safe_term}" == ${term} || "${TERM}" == ${term} ]] ; then
use_color="true"
break
RED="\033[38;5;196m"
YELLOW="\033[38;5;226m"
GREEN="\033[38;5;46m"
- BLUE="\033[38;5;27m"
+ # BLUE="\033[38;5;27m"
CYAN="\033[38;5;36m"
NORMAL="\033[39m"
- HAS_COLORS="y"
else
RED=""
YELLOW=""
GREEN=""
- BLUE=""
+ # 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
- HAS_TTY='n'
- fi
-
}
detect_color
if [[ "${VERBOSE}" != "y" ]] ; then
return 0
fi
- echo -e " * [$(my_date)] [${BASENAME}:${CYAN}DEBUG${NORMAL}]: $@" >&2
+ echo -e " * [$(my_date)] [${BASENAME}:${CYAN}DEBUG${NORMAL}]: $*" >&2
}
#------------------------------------------------------------------------------
return 0
fi
if [[ "${VERBOSE}" == "y" ]] ; then
- echo -e " ${GREEN}*${NORMAL} [$(my_date)] [${BASENAME}:${GREEN}INFO${NORMAL}] : $@"
+ echo -e " ${GREEN}*${NORMAL} [$(my_date)] [${BASENAME}:${GREEN}INFO${NORMAL}] : $*"
else
- echo -e " ${GREEN}*${NORMAL} $@"
+ echo -e " ${GREEN}*${NORMAL} $*"
fi
}
#------------------------------------------------------------------------------
warn() {
if [[ "${VERBOSE}" == "y" ]] ; then
- echo -e " ${YELLOW}*${NORMAL} [$(my_date)] [${BASENAME}:${YELLOW}WARN${NORMAL}] : $@" >&2
+ echo -e " ${YELLOW}*${NORMAL} [$(my_date)] [${BASENAME}:${YELLOW}WARN${NORMAL}] : $*" >&2
else
- echo -e " ${YELLOW}*${NORMAL} [${BASENAME}:${YELLOW}WARN${NORMAL}] : $@" >&2
+ echo -e " ${YELLOW}*${NORMAL} [${BASENAME}:${YELLOW}WARN${NORMAL}] : $*" >&2
fi
}
#------------------------------------------------------------------------------
error() {
if [[ "${VERBOSE}" == "y" ]] ; then
- echo -e " ${RED}*${NORMAL} [$(my_date)] [${BASENAME}:${RED}ERROR${NORMAL}]: $@" >&2
+ echo -e " ${RED}*${NORMAL} [$(my_date)] [${BASENAME}:${RED}ERROR${NORMAL}]: $*" >&2
else
- echo -e " ${RED}*${NORMAL} [${BASENAME}:${RED}ERROR${NORMAL}]: $@" >&2
+ echo -e " ${RED}*${NORMAL} [${BASENAME}:${RED}ERROR${NORMAL}]: $*" >&2
fi
}
set +e
tmp=$( getopt -o "${short_options}" --long "${long_options}" -n "${BASENAME}" -- "$@" )
- if [[ $? != 0 ]] ; then
+ ret="$?"
+ if [[ "${ret}" != 0 ]] ; then
echo "" >&2
usage >&2
exit 1
RED=""
YELLOW=""
GREEN=""
- BLUE=""
+ # BLUE=""
CYAN=""
NORMAL=""
- HAS_COLORS="n"
shift
;;
--nocolor)
RED=""
YELLOW=""
GREEN=""
- BLUE=""
+ # BLUE=""
CYAN=""
NORMAL=""
- HAS_COLORS="n"
shift
;;
-h|--help)
for py_version in "${valid_py_versions[@]}" ; do
python="python${py_version}"
debug "Testing Python binary '${CYAN}${python}${NORMAL}' …"
- if type -t ${python} >/dev/null ; then
+ if type -t "${python}" >/dev/null ; then
found="y"
empty_line
info "Found '${GREEN}${python}${NORMAL}'."
empty_line
- virtualenv --python=${python} venv
+ virtualenv --python="${python}" venv
break
fi
done
fi
fi
+ # shellcheck disable=SC1091
. venv/bin/activate || exit 5
}