SCP taming: stop local silliness
day now and then, I get an scp command wrong. Scp is designed after commands like rcp and works totally fine for local-to-local file copy.
While this can (or could) be useful in some contexts, It's not what I like to do these days; very often, if either hosts is not remote, it's a typo on my part, and results in spurious "email@example.com" files somewhere in various directories on my disk.
So, what I like to do? I put a small script like this in my path before the actual scp executable in order to pre-check arguments, and prevent accidental local-only copies.
#!/bin/bash ORIG="/usr/bin/scp" for var in "$@" do if [[ $var = *":"* ]]; then $ORIG "$@" exit $? fi done echo "ERROR: Missing colon. You need to pass at least one remote host specifier in source or dest" exit 1