From 6b8a1e46b9ca753163874685289df329653b4778 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 00:51:56 +0200 Subject: [PATCH 01/11] disable/3043 --- .shellcheckrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.shellcheckrc b/.shellcheckrc index fb50083..20ef482 100644 --- a/.shellcheckrc +++ b/.shellcheckrc @@ -1,3 +1,3 @@ -disable=2312 +disable=2312,3043 enable=all shell=sh From 6c1dd6fa84d64f3dc2aa009ac45a086ddb39f40b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 00:53:34 +0200 Subject: [PATCH 02/11] tasks/local --- readme.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/readme.md b/readme.md index ecb33bf..736eedb 100644 --- a/readme.md +++ b/readme.md @@ -225,9 +225,7 @@ Handle project workflows in a unified way: * comment * drawing characters constants * handle errors -* locales - * set unicode C - * set unicode language +* local variables * packages * configure * apk From 3634ea4a77d8f13c87acbfe45424e5b73a437066 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 00:55:03 +0200 Subject: [PATCH 03/11] fill --- spcd/bootstrap.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index c7a4f66..41aad1f 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -5,12 +5,11 @@ # ╰───╯ _spcd_fill() { - _spcd_fill__index=${1} - while [ "${_spcd_fill__index}" -gt 0 ]; do + local index=${1} + while [ "${index}" -gt 0 ]; do printf "%s" "${2}" - _spcd_fill__index=$((_spcd_fill__index - 1)) + index=$((index - 1)) done - unset _spcd_fill__index } # ╭───┬────────╮ From 835ad7279c062adf5cc2673c191238fe8d177e8d Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 00:57:21 +0200 Subject: [PATCH 04/11] banner/add --- spcd/bootstrap.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index 41aad1f..666b589 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -27,18 +27,15 @@ _SPCD_BANNER_VERTICAL="│" _spcd_banner_add() { if [ -n "${1}" ]; then - spcd_ba__text=" ${1} " - spcd_ba__length=${#spcd_ba__text} - spcd_ba__filler="$( - _spcd_fill "${spcd_ba__length}" "${_SPCD_BANNER_HORIZONTAL}" - )" + local text=" ${1} " + local length=${#text} + local filler="$(_spcd_fill "${length}" "${_SPCD_BANNER_HORIZONTAL}")" if [ -n "${__SPCD_BANNER_MIDDLE}" ]; then _spcd_banner_split else _spcd_banner_open fi - _spcd_banner_append \ - "${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}" + _spcd_banner_append "${filler}" "${text}" "${filler}" fi } From f257864aba359774576296f09dd07c6867fc8f2f Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 00:59:35 +0200 Subject: [PATCH 05/11] banner/index --- spcd/bootstrap.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index 666b589..52e0ff3 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -40,19 +40,20 @@ _spcd_banner_add() { } _spcd_banner_add_index() { - unset spcd_bai__label - unset spcd_bai__level + local label + local level + local value while true; do - spcd_bai__level=$((spcd_bai__level + 1)) - eval "spcd_bai__value=\"\${__SPCD_STEP_${spcd_bai__level}_INDEX}\"" - [ -n "${spcd_bai__value}" ] || break - if [ -n "${spcd_bai__label}" ]; then - spcd_bai__label="${spcd_bai__label}.${spcd_bai__value}" + level=$((level + 1)) + eval "value=\"\${__SPCD_STEP_${level}_INDEX}\"" + [ -n "${value}" ] || break + if [ -n "${label}" ]; then + label="${label}.${value}" else - spcd_bai__label="${spcd_bai__value}" + label="${value}" fi done - _spcd_banner_add "${spcd_bai__label}" + _spcd_banner_add "${label}" } _spcd_banner_append() { From cd2f40f39883073ebfec507914dc5f7fe27ab2ad Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 01:00:55 +0200 Subject: [PATCH 06/11] banner/render --- spcd/bootstrap.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index 52e0ff3..d3e89a1 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -83,12 +83,13 @@ _spcd_banner_render() { _spcd_banner_add "S" _spcd_banner_add_index # - unset spcd_br__level + local level + local value while true; do - spcd_br__level=$((spcd_br__level + 1)) - eval "spcd_br__value=\"\${__SPCD_STEP_${spcd_br__level}_LABEL}\"" - [ -n "${spcd_br__value}" ] || break - _spcd_banner_add "${spcd_br__value}" + level=$((level + 1)) + eval "value=\"\${__SPCD_STEP_${level}_LABEL}\"" + [ -n "${value}" ] || break + _spcd_banner_add "${value}" done # _spcd_banner_shut From 855ac59ed34f05882e2c265047b7d02e9ded6744 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 01:03:42 +0200 Subject: [PATCH 07/11] os/grep --- spcd/bootstrap.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index d3e89a1..ccea737 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -221,10 +221,10 @@ spcd_openssl_x509() { # ╰───────────┴────╯ spcd_os_grep() { - spcd_os_grep__variable="${1}" - [ -n "${spcd_os_grep__variable}" ] && - grep "^${spcd_os_grep__variable}=" "/etc/os-release" | - sed "s|^${spcd_os_grep__variable}=||" | + local variable="${1}" + [ -n "${variable}" ] && + grep "^${variable}=" "/etc/os-release" | + sed "s|^${variable}=||" | sed "s|^\"\(.*\)\"$|\1|" } From 2b37cc94797fe60a1056f90b30b971312d361968 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 01:04:15 +0200 Subject: [PATCH 08/11] fix/"" --- spcd/bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index ccea737..fcaa398 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -5,7 +5,7 @@ # ╰───╯ _spcd_fill() { - local index=${1} + local index="${1}" while [ "${index}" -gt 0 ]; do printf "%s" "${2}" index=$((index - 1)) From e0552167bf5716a3c4743a25eebf2c4c711ac6ab Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 01:10:37 +0200 Subject: [PATCH 09/11] os/printenv --- spcd/bootstrap.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index fcaa398..8133189 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -243,10 +243,11 @@ spcd_os_mkdir() { spcd_os_printenv() { if [ -n "${1}" ]; then - for spcd_os_printenv__name in "${@}"; do - spcd_os_printenv__text="" - eval "spcd_os_printenv__text=\"\${${spcd_os_printenv__name}}\"" - echo "${spcd_os_printenv__name} = \"${spcd_os_printenv__text}\"" + local name + local text + for name in "${@}"; do + eval "text=\"\${${name}}\"" + echo "${name} = \"${text}\"" done fi } From 6f3c5a814343372e318157dc288fe14f7a39e8b8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 01:12:11 +0200 Subject: [PATCH 10/11] os/sed --- spcd/bootstrap.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index 8133189..6764c83 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -260,13 +260,14 @@ spcd_os_rm() { } spcd_os_sed() { - spcd_os_sed__file="${1}" + local file="${1}" shift - if [ -f "${spcd_os_sed__file}" ]; then - _spcd_os_cat "${spcd_os_sed__file}" - for spcd_os_sed__regex in "${@}"; do - sed --in-place "s${spcd_os_sed__regex}g" "${spcd_os_sed__file}" && - _spcd_os_cat "${spcd_os_sed__file}" + if [ -f "${file}" ]; then + local regex + _spcd_os_cat "${file}" + for regex in "${@}"; do + sed --in-place "s${regex}g" "${file}" && + _spcd_os_cat "${file}" done fi } From 31ca2c6117fd9726944205e63f20163b207d570a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 31 Aug 2024 01:13:08 +0200 Subject: [PATCH 11/11] os/write --- spcd/bootstrap.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spcd/bootstrap.sh b/spcd/bootstrap.sh index 6764c83..c80c600 100644 --- a/spcd/bootstrap.sh +++ b/spcd/bootstrap.sh @@ -273,14 +273,14 @@ spcd_os_sed() { } spcd_os_write() { - spcd_os_write__file="${1}" - spcd_os_write__text="${2}" - if [ -n "${spcd_os_write__file}" ]; then - [ -f "${spcd_os_write__file}" ] && - _spcd_os_cat "${spcd_os_write__file}" - echo "→ ${spcd_os_write__file}" - printf "%s" "${spcd_os_write__text}" >"${spcd_os_write__file}" - _spcd_os_cat "${spcd_os_write__file}" + local file="${1}" + local text="${2}" + if [ -n "${file}" ]; then + [ -f "${file}" ] && + _spcd_os_cat "${file}" + echo "→ ${file}" + printf "%s" "${text}" >"${file}" + _spcd_os_cat "${file}" fi }