Compare commits

...

11 commits

Author SHA1 Message Date
31ca2c6117
os/write
Some checks failed
/ arch (push) Successful in 2m46s
/ alpine (push) Successful in 1m57s
/ fedora (push) Successful in 12m59s
/ opensuse (push) Successful in 3m36s
/ alma (push) Successful in 12m53s
/ rocky (push) Successful in 12m49s
/ ubuntu (push) Successful in 5m54s
/ debian (push) Failing after 3m25s
2024-08-31 01:13:08 +02:00
6f3c5a8143
os/sed 2024-08-31 01:12:11 +02:00
e0552167bf
os/printenv 2024-08-31 01:10:37 +02:00
2b37cc9479
fix/"" 2024-08-31 01:04:15 +02:00
855ac59ed3
os/grep 2024-08-31 01:03:42 +02:00
cd2f40f398
banner/render 2024-08-31 01:00:55 +02:00
f257864aba
banner/index 2024-08-31 00:59:35 +02:00
835ad7279c
banner/add 2024-08-31 00:57:21 +02:00
3634ea4a77
fill 2024-08-31 00:55:03 +02:00
6c1dd6fa84
tasks/local 2024-08-31 00:53:34 +02:00
6b8a1e46b9
disable/3043 2024-08-31 00:51:56 +02:00
3 changed files with 49 additions and 51 deletions

View file

@ -1,3 +1,3 @@
disable=2312
disable=2312,3043
enable=all
shell=sh

View file

@ -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

View file

@ -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
}
# ╭───┬────────╮
@ -28,35 +27,33 @@ _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
}
_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() {
@ -86,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
@ -223,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|"
}
@ -245,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
}
@ -261,26 +260,27 @@ 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
}
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
}