Add functions.sh

Replace repetitive code
This commit is contained in:
0x1eef 2024-07-19 03:26:14 -03:00
parent d5770bc731
commit 19c465d6be
9 changed files with 26 additions and 81 deletions

View file

@ -10,15 +10,7 @@ doas="${localbase}"/etc/doas.conf
## ##
# functions # functions
printok() . "${libexec}"/functions.sh
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
## ##
# main # main

View file

@ -10,20 +10,7 @@ branch=$2
## ##
# functions # functions
git() . "${libexec}"/functions.sh
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
## ##
# main # main
@ -42,9 +29,7 @@ if [ ! -e "${gitdir}/.git" ]; then
exit 1 exit 1
fi fi
set -x
cd "${gitdir}" cd "${gitdir}"
git fetch origin git fetch origin
git checkout "${branch}" || git checkout -t origin/"${branch}" git checkout "${branch}" || git checkout -t origin/"${branch}"
set +x
printok "${branch} checked out" printok "${branch} checked out"

View file

@ -11,20 +11,7 @@ branch=$3
## ##
# functions # functions
git() . "${libexec}"/functions.sh
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
## ##
# main # main

View file

@ -12,6 +12,8 @@ revfile=$3
## ##
# functions # functions
. "${libexec}"/functions.sh
perform_update() perform_update()
{ {
rev=$(cat "${revfile}") rev=$(cat "${revfile}")
@ -63,21 +65,6 @@ run_install()
install -o root -g _sourcezap -m "${mode}" -v "$@" install -o root -g _sourcezap -m "${mode}" -v "$@"
} }
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
## ##
# main # main
if [ "$(id -u)" != "0" ]; then if [ "$(id -u)" != "0" ]; then

View file

@ -9,20 +9,7 @@ gitdir=$1
## ##
# functions # functions
git() . "${libexec}"/functions.sh
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
## ##
# main # main

View file

@ -10,6 +10,8 @@ installdir=$2
## ##
# functions # functions
. "${libexec}"/functions.sh
erase() erase()
{ {
dir="${1}" dir="${1}"
@ -24,11 +26,6 @@ erase()
echo echo
} }
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
## ##
# main # main
if [ "$(id -u)" != "0" ]; then if [ "$(id -u)" != "0" ]; then

View file

@ -0,0 +1,16 @@
#!/bin/sh
git()
{
"${libexec}"/utils/git/run "${@}"
}
printok()
{
"${libexec}"/utils/printok "${@}"
}
printerr()
{
"${libexec}"/utils/printerr "${@}"
}

View file

@ -10,10 +10,7 @@ commit=$2
## ##
# functions # functions
git() . "${libexec}"/functions.sh
{
"${libexec}"/utils/git/run "${@}"
}
## ##
# main # main

View file

@ -10,10 +10,7 @@ commit=$2
## ##
# functions # functions
git() . "${libexec}"/functions.sh
{
"${libexec}"/utils/git/run "${@}"
}
## ##
# main # main