aboutsummaryrefslogtreecommitdiff
path: root/spec/spec_helper.sh
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-02-04 10:11:35 +0000
committermerakor <cem@ckyln.com>2021-02-04 10:11:35 +0000
commit63c4051197cfcad2231de6eb9874055d668f47df (patch)
tree53d3b3e340570e1dda7d763a5071bafe0ad56543 /spec/spec_helper.sh
parent37d93c5413b1025c8490b57edf2dea821320d2ca (diff)
parent8d5398a76eda8beec3e7458a1400b9a363afce3d (diff)
downloadcpt-63c4051197cfcad2231de6eb9874055d668f47df.tar.gz
Merge branch 'shellspec'
FossilOrigin-Name: 9f02ac446d6b0e692389a85882df0ff8b2ac54ea40c0f040c5c4dd1713456a21
Diffstat (limited to 'spec/spec_helper.sh')
-rw-r--r--spec/spec_helper.sh20
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
+}