mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Added a multi-line example that works with Bash 3.x
@@ -11,9 +11,12 @@ array=( $(mycommand) )
|
||||
If it outputs multiple lines, each of which should be an element:
|
||||
|
||||
```sh
|
||||
# For bash
|
||||
# For bash 4.x
|
||||
mapfile -t array < <(mycommand)
|
||||
|
||||
# For bash 3.x+
|
||||
while IFS=$'\n' read -r line; do array+=("$line"); done < <(mycommand)
|
||||
|
||||
# For ksh
|
||||
mycommand | while IFS="" read -r line; do array+=("$line"); done
|
||||
```
|
||||
|
Reference in New Issue
Block a user