From 731f0c9d775b2cbb6fa77d8bbe1c505b16fa6abf Mon Sep 17 00:00:00 2001 From: merakor Date: Thu, 4 Nov 2021 12:34:27 +0000 Subject: sepchar: simplify FossilOrigin-Name: 45602b1963d7ef0f2e3ec7489883e14803a8881798339fe2a61701305451abc0 --- src/cpt-lib.in | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 1280765..b01790d 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -132,20 +132,16 @@ trap_set() { esac } -sepchar() ( +sepchar() { # Seperate every character on the given string without resorting to external # processes. [ "$1" ] || return 0; str=$1; set -- while [ "$str" ]; do - str_tmp=$str - for i in $(_seq $(( ${#str} - 1 ))); do - str_tmp=${str_tmp%?} - done - set -- "$@" "$str_tmp" - str=${str#$str_tmp} + set -- "$@" "${str%${str#?}}" + str=${str#?} done printf '%s\n' "$@" -) +} _re() { # Check that the string supplied in $2 conforms to the regular expression -- cgit v1.2.3