using mapfile instead of read ( require v4 bash )

This commit is contained in:
elreydetoda 2021-06-18 08:29:56 -04:00 committed by GitHub
parent 8c19d0b482
commit a1a7795c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -308,7 +308,7 @@ This is an alternative to `cut`, `awk` and other tools.
```sh
split() {
# Usage: split "string" "delimiter"
IFS=$'\n' read -d "" -ra arr <<< "${1//$2/$'\n'}"
mapfile -t arr <<< "${1//$2/$'\n'}"
printf '%s\n' "${arr[@]}"
}
```