As pointed out by ΓlvaroG.Vicario, backticks (and $() ) remove trailing newlines. There does not slip away, so if you need to, you have to get around this:
#!/usr/bin/env bash function1() { printf '%s' "cat" } function2() { printf '%s' "dog" } function3() { printf '%s' "mouse" } for function in\ function1\ function2\ function3; do array[$((index++))]=$($function) done
source share