diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2023-03-21 10:03:04 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2023-03-21 10:03:04 -0700 |
commit | 7d30dbc6a8b0a267a0769cf94bfa6cd643a886f5 (patch) | |
tree | 9c18bdc85745bca9dc9328b62b9a44ada6fc5c06 | |
parent | 91ccccb4204457349fff4c55c3bb0d9c85a5e342 (diff) | |
download | rbpm-7d30dbc6a8b0a267a0769cf94bfa6cd643a886f5.tar.gz rbpm-7d30dbc6a8b0a267a0769cf94bfa6cd643a886f5.tar.xz |
improve array loading, no more xargs
-rw-r--r-- | README | 1 | ||||
-rwxr-xr-x | rbpm.sh | 10 |
2 files changed, 4 insertions, 7 deletions
@@ -20,7 +20,6 @@ DEPENDENCIES bash (>= 4.0) coreutils (sort) - findutils (xargs) INSTALLING @@ -44,10 +44,8 @@ _populate_dirs() { [[ -d "${RUBIES_PATH}" ]] \ || _die "directory ${RUBIES_PATH} does not exist." - # Cannot handle paths containing a newline. Only an idiot would - # encounter this in practice. - readarray -t dirs < <(shopt -s nullglob; \ - printf '%s\0' "${RUBIES_PATH}"/* | sort -zV | xargs -0n1) + mapfile -td $'\0' dirs < <(shopt -s nullglob; + printf '%s\0' "${RUBIES_PATH}"/* | sort -zV) [[ -n "${dirs}" ]] || _die "directory ${RUBIES_PATH} is empty." } @@ -55,7 +53,7 @@ _populate_dirs() { _populate_selected() { local dir dirs - IFS=':' read -a dirs <<< "${PATH}" + mapfile -td ':' dirs < <(printf %s "${PATH}") for dir in "${dirs[@]}"; do if [[ "${dir}" == "${RUBIES_PATH}/"* ]]; then @@ -72,7 +70,7 @@ _populate_selected() { _clear() { local dir dirs cdirs - IFS=':' read -a dirs <<< "${PATH}" + mapfile -td ':' dirs < <(printf %s "${PATH}") for dir in "${dirs[@]}"; do if [[ "${dir}" == "${RUBIES_PATH}/"* ]]; then |