If I run
mapfile -t array_files < <(ssh -i key user@host "find / -name search -type f")
and print the results in $?, I receive 0 even when the command fail.
If I run
mapfile -t array_files < <(ssh -i key user@host "find / -name search -type f")
and print the results in $?, I receive 0 even when the command fail.
With bash.
# disable job control and enable lastpipe to run mapfile in current environment
set +m; shopt -s lastpipe
# feed array_files with the output of your ssh/find command
ssh ... | mapfile -t array_files
# returncode of first command in pipe (here ssh)
echo "${PIPESTATUS[0]}"
# content of array array_files
declare -p array_files
In a script job control is disabled by default.