diff options
author | merakor <cem@ckyln.com> | 2021-01-06 11:56:09 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-01-06 11:56:09 +0000 |
commit | ae42d4a74240d452864cdf16ce2ac2cbbdb5fc68 (patch) | |
tree | 555426dbde9aec2f5c22154bd21b416f14151d05 /spec/spec_helper.sh | |
parent | 12a4321bfdc98c3bf7b1440077c1a09c9f4e3eec (diff) | |
download | cpt-ae42d4a74240d452864cdf16ce2ac2cbbdb5fc68.tar.gz |
shellspec: add spec_helper
FossilOrigin-Name: df5c93b3f164a3826c97d1ca43924d44af1a5e156e2c4b2f0b8496c60b652868
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 +} |