malatos:~>cat bin/deluge
#! /bin/bash
ARGS=
for arg in "$@"; do
ARGS+="\"$(echo $arg | sed -e 's/\\/\\\\/g;s/"/\\"/g')\" "
done
echo "ARGS=$ARGS"
ssh hikaru ls $ARGS
malatos:~>deluge a b 'a b' '"x y"' 'x\y' 'x\\y'
ARGS="a" "b" "a b" "\"x y\"" "x\\y" "x\\\\y"
ls: cannot access a: No such file or directory
ls: cannot access b: No such file or directory
ls: cannot access a b: No such file or directory
ls: cannot access "x y": No such file or directory
ls: cannot access x\y: No such file or directory
ls: cannot access x\\y: No such file or directory