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
printok()
{
"${libexec}"/utils/printok "${1}"
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
. "${libexec}"/functions.sh
##
# main

View file

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

View file

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

View file

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

View file

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

View file

@ -10,6 +10,8 @@ installdir=$2
##
# functions
. "${libexec}"/functions.sh
erase()
{
dir="${1}"
@ -24,11 +26,6 @@ erase()
echo
}
printerr()
{
"${libexec}"/utils/printerr "${1}"
}
##
# main
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
git()
{
"${libexec}"/utils/git/run "${@}"
}
. "${libexec}"/functions.sh
##
# main

View file

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