aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2021-01-03 22:00:59 +0000
committermerakor <cem@ckyln.com>2021-01-03 22:00:59 +0000
commit67ca267cd28e82a90bdf8abd38b6e1c25ffb59e9 (patch)
tree3d0ccda2b22d3bf6e7b5681b6d968332ef002cb1 /src
parent5c56af98e95d12fd4531cd9197657eace1fe8bc1 (diff)
downloadcpt-67ca267cd28e82a90bdf8abd38b6e1c25ffb59e9.tar.gz
_seq(): add function to print numbers sequentially
FossilOrigin-Name: e512f7d12e12c16fe109cfdf642361bb46ba594273ecacd93531c0ddfb144a8e
Diffstat (limited to 'src')
-rw-r--r--src/cpt-lib.in9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/cpt-lib.in b/src/cpt-lib.in
index 73e483c..5e5e7b4 100644
--- a/src/cpt-lib.in
+++ b/src/cpt-lib.in
@@ -45,6 +45,15 @@ trap_set() {
esac
}
+_seq() (
+ # Pure shell counter meant to be used in 'for' loops.
+ i=0 buf=''
+ while [ "$(( i += 1 ))" -le "$1" ]; do
+ buf="$buf $i "
+ done
+ printf '%s' "$buf"
+)
+
_stat() (
_user=; eval set -- "$(ls -ld "$1")"
id -u "${_user:=$3}" >/dev/null 2>&1 || _user=root