aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKylie McClain <kylie@somas.is>2020-07-07 08:52:57 -0400
committerKylie McClain <kylie@somas.is>2020-07-07 09:33:53 -0400
commit721819850c2a3bd3e59a0abf8fc00c8563cf4efb (patch)
tree0cb70ca62131f7e873c68665edff4ff2db2d717d
parent5608842788d0ecb4c83bff8a61b9e2e32737a65d (diff)
downloadpraxis-721819850c2a3bd3e59a0abf8fc00c8563cf4efb.tar.gz
praxis-721819850c2a3bd3e59a0abf8fc00c8563cf4efb.tar.xz
praxis-721819850c2a3bd3e59a0abf8fc00c8563cf4efb.zip
action, theory.sh: fully rely on idioms usage
-rw-r--r--action.in32
-rwxr-xr-xtheory-construct-action.in2
-rwxr-xr-xtheory-construct-metadata.in2
-rw-r--r--theory.sh.in16
4 files changed, 16 insertions, 36 deletions
diff --git a/action.in b/action.in
index 0063251..f06f719 100644
--- a/action.in
+++ b/action.in
@@ -1,27 +1,5 @@
#!/bin/sh
-estderr() {
- # shellcheck disable=SC2059
- printf "$@" >&2
-}
-
-edie() {
- [ "$#" -gt 0 ] && estderr "$@"
- exit 1
-}
-
-eerror() {
- edie "${color_bold}${color_red}!!${color_reset} %s\n" "$@"
-}
-
-ewarning() {
- estderr "${color_bold}${color_yellow}!?${color_reset} %s\n" "$@"
-}
-
-einfo() {
- printf "${color_bold}${color_green}..${color_reset} %s\n" "$@"
-}
-
default_pkg_init() { :; }
default_src_fetch() {
@@ -30,8 +8,8 @@ default_src_fetch() {
while [ $# -gt 0 ]; do
local output="${FETCHDIR}"/"$(basename "$1")"
if ! [ -f "${output}" ]; then
- edo curl -# -L -C - -o "${output}".part "$1"
- edo mv "${output}".part "${output}"
+ call curl -# -L -C - -o "${output}".part "$1"
+ call mv "${output}".part "${output}"
fi
shift
@@ -50,8 +28,8 @@ pkg_init() { default_pkg_init "$@"; }
src_fetch() { default_src_fetch "$@"; }
src_unpack() { default_src_unpack "$@"; }
src_prepare() { default_src_prepare "$@"; }
-src_configure() { eerror -d "phase 'src_configure' is not defined!\n"; }
-src_test() { eerror -d "phase 'src_test' is not defined!\n"; }
-src_install() { eerror -d "phase 'src_install' is not defined!\n"; }
+src_configure() { die 100 "phase 'src_configure' is not defined!"; }
+src_test() { die 100 "phase 'src_test' is not defined!"; }
+src_install() { die 100 "phase 'src_install' is not defined!"; }
pkg_premerge() { default_pkg_premerge "$@"; }
pkg_postmerge() { default_pkg_postmerge "$@"; }
diff --git a/theory-construct-action.in b/theory-construct-action.in
index a422534..bd01eb9 100755
--- a/theory-construct-action.in
+++ b/theory-construct-action.in
@@ -19,7 +19,7 @@ while getopts :r arg >/dev/null 2>&1; do
done
shift $(( OPTIND - 1 ))
-[ "$#" -eq 0 ] && myusage
+[ "$#" -gt 0 ] || myusage
while [ "$#" -gt 0 ]; do
if ! is_theory_dir "${1}"; then
diff --git a/theory-construct-metadata.in b/theory-construct-metadata.in
index 6a45297..05d1340 100755
--- a/theory-construct-metadata.in
+++ b/theory-construct-metadata.in
@@ -19,7 +19,7 @@ while getopts :a:o:r arg >/dev/null 2>&1; do
done
shift $(( OPTIND - 1 ))
-[ "$#" -gt 0 ] || usage
+[ "$#" -gt 0 ] || myusage
while [ "$#" -gt 0 ]; do
is_theory_dir "${1}" || die 2 "'${1}' is not a directory containing a package or library"
diff --git a/theory.sh.in b/theory.sh.in
index 7c0eb97..666bca4 100644
--- a/theory.sh.in
+++ b/theory.sh.in
@@ -2,7 +2,7 @@
# at a bare minimum, a directory is a theory package/library directory if it contains an action or a library.
is_theory_dir() {
- [ -d "${1}" ] || perror -d "'%s' is not a directory\n" "${1}"
+ [ -d "${1}" ] || die 2 "'${1}' is not a directory"
[ -r "${1}"/action ] && [ -s "${1}"/action ] && return 0
[ -r "${1}"/libraries ] && [ -s "${1}"/libraries ] && return 0
@@ -11,7 +11,7 @@ is_theory_dir() {
}
is_repo_dir() {
- [ -d "${1}" ] || perror -d "'%s' is not a directory\n" "${1}"
+ [ -d "${1}" ] || die 2 "'${1}' is not a directory"
[ -d "${1}"/packages ] && [ -d "${1}"/metadata ] &&
[ -d "${1}"/libraries ] && [ -d "${1}"/metadata ] &&
@@ -21,17 +21,19 @@ is_repo_dir() {
}
is_pkg_dir() {
- [ -d "${1}" ] || perror -d "'%s' is not a directory\n" "${1}"
+ [ -d "${1}" ] || die 2 "'${1}' is not a directory"
- basename "${1}" | grep -Eq "^[A-Za-z][A-Za-z0-9_+-]*#[a-z0-9\._-]+$" &&
- is_theory_dir "${1}" &&
- return 0
+ match -E "^[A-Za-z][A-Za-z0-9_+-]*#[a-z0-9\._-]+$" "$(basename "${1}")" \
+ && is_theory_dir "${1}" \
+ && return 0
return 1
}
is_lib_dir() {
- [ -d "${1}" ] || perror -d "'%s' is not a directory\n" "${1}"
+ [ -d "${1}" ] || die 2 "'${1}' is not a directory"
+
! is_pkg_dir "${1}" && is_theory_dir "${1}" && return 0
+
return 1
}