Not that sure if it comes with drawbacks, but you can just ssh@remote <command>
Quick test this seems to work:
Code: Select all
$ v=($(ssh void-raspberry find Programming -type d -maxdepth 1))
$ for i in "${v[@]}"; do printf "%s\n" "$i"; done
Programming
Programming/bash
Programming/notabug
$
https://shellcheck.net complains about that and proposes mapfile instead:
Code: Select all
$ mapfile -t v < <(ssh void-raspberry find Programming -maxdepth 1 -type d)
If it is a critical project, i would ask in #bash. As soon ssh is involved, it gets messy (as in: not hard to oversee something).
Looking at your fragment some comments (perhaps superfluous) which might not be correct, but are just usual/general statements (not for your specific case, which i don't fully understand
) :
never ever parse ls
http://mywiki.wooledge.org/ParsingLs
qefs: "$Quote" "$Every" "$******" "$Substitution"
if it was me i would exit as soon an mkdir gives an error (not sure about that one though).
Perhaps i misunderstood you. If so, sorry. Don't take my word for it anyway. Make sure to double- and even triplecheck, i might well be wrong.
Good luck.