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