mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-04 03:46:06 +08:00
Move link into text and point to the "right" answer.
@@ -24,13 +24,12 @@ mapfile -t array <<< "$var"
|
|||||||
printf '%s\n' "$var" | while IFS="" read -r line; do array+=("$line"); done
|
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:
|
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 and ksh
|
||||||
IFS=" " read -r -a array <<< "$var"
|
IFS=" " read -r -a array <<< "$var"
|
||||||
```
|
```
|
||||||
1. https://stackoverflow.com/questions/1469849
|
|
||||||
|
|
||||||
### Rationale:
|
### Rationale:
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user