From 475a563280333c1b5f59bab78e084367d8b2d148 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Sun, 16 Apr 2023 16:39:41 +0900 Subject: [PATCH] feat(lib/utils): Add "_omb_util_split" --- lib/utils.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/utils.sh b/lib/utils.sh index 0504758..6fcee39 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -364,6 +364,15 @@ function _omb_util_add_prompt_command { fi } +## @fn _omb_util_split array str [sep] +function _omb_util_split { + local __set=$- IFS=${3:-$' \t\n'} + set -f + eval -- "$1=(\$2)" + [[ $__set == *f* ]] || set +f + return 0 +} + function _omb_util_glob_expand { local __set=$- __shopt __gignore=$GLOBIGNORE _omb_util_get_shopt failglob nullglob extglob