diff options
Diffstat (limited to 'spec/spec_helper.sh')
-rw-r--r-- | spec/spec_helper.sh | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/spec_helper.sh b/spec/spec_helper.sh new file mode 100644 index 0000000..f62d9f6 --- /dev/null +++ b/spec/spec_helper.sh @@ -0,0 +1,20 @@ +# shellcheck shell=sh + +pkgnum() { + i=0 + cd "$CPT_ROOT/var/db/cpt/installed" || { printf '%s\n' 0; return 1 ;} + for pkg in ./*; do + [ -d "$pkg" ] || break + i=$(( i + 1 )) + done + printf '%s\n' "$i" +} + +getfirstpkg() { + cd "$CPT_ROOT/var/db/cpt/installed" || return 1 + for pkg in ./*; do + [ -d "$pkg" ] || return 1 + printf '%s\n' "${pkg##*/}" + break + done +} |