I needed to write a that behaves correctly with nasty (spaces, braces, etc..)
filenames.
scp -rv "$1" shiny:/Volumes/Seagate3To/\"$1\"
This function works, but I don't understand why the quotes need escaping in the second argument of scp
.
quotingscpzsh
I needed to write a that behaves correctly with nasty (spaces, braces, etc..)
filenames.
scp -rv "$1" shiny:/Volumes/Seagate3To/\"$1\"
This function works, but I don't understand why the quotes need escaping in the second argument of scp
.
Best Answer
Let say $1 is
We escape the double quote because we want to pass the target directory (part after colon) as a whole (including the double quotes) to the target machine.
Following is what we want to past to target
Without the escape, the double quote will be consumed by the local machine and following string is sent, which become 6 strings separated by space
Resulting an error.