--===============1455858774==
Content-Type: multipart/signed; micalg=pgp-sha1;
protocol="application/pgp-signature";
boundary="=-zLookKrqb1HQTaE/7LnP"


--=-zLookKrqb1HQTaE/7LnP
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Paul has addressed the errant dollar signs, the misspelled $DST, and two
possible workarounds for the quoting issue, but I would like to explain
the quoting issue a bit further.

On Fri, 2008-04-04 at 11:23 -0400, Sterling Windmill wrote:
> RSYNC_OPTIONS=3D"-aH --delete --numeric-ids -e \'ssh -p 2292\'"
> RSYNC=3D"ionice -c3 rsync $RSYNC_OPTIONS"
> =20
> $SOURCE=3D/some/dir
> $DEST=3Droot@10.2.10.1:/some/dir
> =20
> $RSYNC --progress "$SOURCE" "$DST"


> Missing trailing-' in remote-shell command.
> rsync error: syntax or usage error (code 1) at main.c(364)
> [sender=3D3.0.0]
> =20
> If I paste the command directly into a command line, the command works
> properly.


First, get rid of the backslashes in $RSYNC_OPTIONS because they are
being taken literally; single quotes need no escaping inside double
quotes.

Second, when bash expands a variable like $RSYNC, it takes quotes in the
variable's value literally; they do not protect spaces in the expanded
value from word splitting. Thus, bash is splitting your -e value into
three pieces, the first and last of which contain unmatched single
quotes, hence the rsync error.

You could fix this by using "eval" instead of word-splitting expansion,
but that would be fragile with respect to shell metacharacters in the
arguments to be passed to rsync. Alternatively...

> I've also tried taking the advice mentioned here and using an array
> instead of a variable, but to no avail:
> =20
> http://wooledge.org:8000/BashFAQ/050


Arrays are generally the best solution, but it takes some care to use
them correctly. Here's your script rewritten to use arrays:

---

RSYNC_OPTIONS=3D(-aH --delete --numeric-ids -e 'ssh -p 2292')
RSYNC=3D(ionice -c3 rsync "${RSYNC_OPTIONS[@]}")

SOURCE=3D/some/dir
DEST=3Droot@10.2.10.1:/some/dir

: "${RSYNC[@]}" --progress "$SOURCE" "$DEST"

---

Matt

--=-zLookKrqb1HQTaE/7LnP
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBH9lUuC+xSYN/RlfsRAsEAAJ0S+eXJxImQKqS1C9gvMSqiwSV9NwCePOu8
7/RTB1eruU5iLOazI57jhoY=
=lar9
-----END PGP SIGNATURE-----

--=-zLookKrqb1HQTaE/7LnP--


--===============1455858774==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

--
To unsubscribe or change options: https://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.catb.org/~esr/faqs/smart-questions.html
--===============1455858774==--