From 67ca267cd28e82a90bdf8abd38b6e1c25ffb59e9 Mon Sep 17 00:00:00 2001 From: merakor Date: Sun, 3 Jan 2021 22:00:59 +0000 Subject: _seq(): add function to print numbers sequentially FossilOrigin-Name: e512f7d12e12c16fe109cfdf642361bb46ba594273ecacd93531c0ddfb144a8e --- src/cpt-lib.in | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- cgit v1.2.3