Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • The arguments resulting of the expansion of "${files[@]}" are joined with spaces by ssh and added to the end of the code interpreted by the login shell of the remote user. You'd need to quote each file in the syntax of that shell or it won't work (and introduce ACE vulnerabilities) if any of those file paths contain characters special in the syntax of that shell (nothing to do with $IFS). Commented Aug 9 at 10:03
  • Yeah, piping a NUL separated file list into perl or bash mapfile / readarray on the remote end or something like that is better. Bash quoting issues suck, and they're made worse by nested quoting levels and how ssh handles args - there are reasons for that, but that doesn't stop it sucking. There are workarounds (like piping the file list, @Q, scp a script, or using declare / typeset in a heredoc like in Charles Duffy's answer in the SFault like I posted in a comment), you just can't use the simple/naive approach unless you're absolutely certain the filenames or other args wont be a problem. Commented Aug 9 at 12:28