The "read" command in ksh for arrays takes upper-case -A param; otherwise the command is identical to the bash version.

scottdcoulter
2020-08-31 09:40:12 -04:00
parent 6f96f35adc
commit 8f255659a0

@@ -27,8 +27,11 @@ printf '%s\n' "$var" | while IFS="" read -r line; do array+=("$line"); done
If it's a line with multiple words (separated by spaces, other delimiters can be chosen with IFS), [each of which should be an element](https://stackoverflow.com/a/30212526): If it's a line with multiple words (separated by spaces, other delimiters can be chosen with IFS), [each of which should be an element](https://stackoverflow.com/a/30212526):
```sh ```sh
# For bash and ksh # For bash
IFS=" " read -r -a array <<< "$var" IFS=" " read -r -a array <<< "$var"
# For ksh
IFS=" " read -r -A array <<< "$var"
``` ```
### Rationale: ### Rationale: