diff options
author | merakor <cem@ckyln.com> | 2021-11-04 12:34:27 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2021-11-04 12:34:27 +0000 |
commit | 731f0c9d775b2cbb6fa77d8bbe1c505b16fa6abf (patch) | |
tree | 854bdc72fc7f447080000219c940bd952d2fdc92 | |
parent | eb16aede0f1d7c1c35f552181879fe794ebe7087 (diff) | |
download | cpt-731f0c9d775b2cbb6fa77d8bbe1c505b16fa6abf.tar.gz |
sepchar: simplifytsort
FossilOrigin-Name: 45602b1963d7ef0f2e3ec7489883e14803a8881798339fe2a61701305451abc0
-rw-r--r-- | src/cpt-lib.in | 12 |
1 files 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 |