Lowercase non-exported vars

This commit is contained in:
dabruh 2022-12-14 20:29:00 +01:00
parent 4db75aa36c
commit 5690e8d1ce
1 changed files with 8 additions and 9 deletions

View File

@ -4,9 +4,8 @@
# Default variables
#
UPGRADE_PACKAGES=false
SCRIPT_NAME="$(basename -- "$0")"
SCRIPT_DIR="$(
upgrade_packages=false
script_dir="$(
cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit 1
pwd -P
)"
@ -16,7 +15,7 @@ SCRIPT_DIR="$(
#
function usage() {
echo "Usage: $SCRIPT_NAME [OPTIONS]"
echo "Usage: $(basename -- "$0") [OPTIONS]"
echo
echo "Options:"
echo " -h Display help."
@ -27,7 +26,7 @@ function usage() {
while getopts ":uh" arg; do
case $arg in
h) usage ;;
u) UPGRADE_PACKAGES=true ;;
u) upgrade_packages=true ;;
:)
echo "$0: Must supply an argument to -$OPTARG." >&2
exit 1
@ -56,7 +55,7 @@ function is_laptop() {
# Returns a comma-separated list of packages for one or more targets.
# The packages file may contain multiple rows with the same target name.
function get_packages() {
local pkg_file="$SCRIPT_DIR/.installer/packages"
local pkg_file="$script_dir/.installer/packages"
for target in "$@"; do
while read -r row; do
@ -155,7 +154,7 @@ function setup_brew_formulas() {
for package in $(get_packages "${targets[@]}"); do
if brew list --full-name | grep -Eq "(^| )$package($| )" >/dev/null; then
if $UPGRADE_PACKAGES; then
if $upgrade_packages; then
echo "Package '$package' will be upgraded."
brew upgrade "$package" || return 2
else
@ -191,7 +190,7 @@ function setup_krew_plugins() {
for package in $(get_packages "${targets[@]}"); do
if kubectl-krew list | grep -q "^$package$" >/dev/null; then
if $UPGRADE_PACKAGES; then
if $upgrade_packages; then
echo "Package '$package' will be upgraded."
else
echo "Package '$package' already exists."
@ -246,7 +245,7 @@ function setup_arch_with_yay() {
for package in $(get_packages "${targets[@]}"); do
if pacman -Qs "^$package$" >/dev/null; then
if $UPGRADE_PACKAGES; then
if $upgrade_packages; then
echo "Package '$package' will be upgraded."
else
echo "Package '$package' already exists."