Content-Type: multipart/signed; micalg=pgp-sha1;

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@
> =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

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[@]}")


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



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

Version: GnuPG v1.4.7 (GNU/Linux)



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