Invoking rsync from a script with null parameters

Kevin Korb kmk at sanitarium.net
Sun Nov 4 20:35:04 MST 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I suspect you are missing a space somewhere and are ending up with 2
parameters stuck together. You can have bash output the rsync command
line it intends to run to make sure or you can just use " " instead of
"" as extra spaces between parameters will have no effect.

On 11/04/12 22:23, Joe wrote:
> I'm working on a bash backup script using rsync. (kubuntu precise
> 12.04, rsync 3.0.9-1ubuntu1)
> 
> To avoid having a number of slightly different rsync commands, I
> would like to use shell variables as part of the rsync command.
> I.e.: DRYRUN="-n" rsync "${DRYRUN}" more parameters ...
> 
> This does not work if DRYRUN="" - apparently because this command
> becomes rsync "" more parameters ... instead of rsync more
> parameters ...
> 
> and rsync uses the null parameter for something and does not
> perform as expected.  It does not generate any error or diagnostic
> message.
> 
> Is there a way to get around this problem - other than coding each 
> permutation of the command separately?
> 
> I'm experimenting with putting the whole rsync command in a string
> so I can run it after any null parameters revert to pure white
> space.  Once I get the quoting to work (preserving those quotes I
> still need), this method should work, but it's less than elegant.
> 
> Is this a bug in rsync?  (Shouldn't it at least complain/error exit
> if it gets something like this that it doesn't understand?)  If it
> is, what's the best way to report it?
> 
> Ideally (for me anyway), I would like it to completely ignore any
> null parameters, but I don't know what problems that might cause
> for other people.
> 
> TIA
> 
> Joe
> 

- -- 
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~
	Kevin Korb			Phone:    (407) 252-6853
	Systems Administrator		Internet:
	FutureQuest, Inc.		Kevin at FutureQuest.net  (work)
	Orlando, Florida		kmk at sanitarium.net (personal)
	Web page:			http://www.sanitarium.net/
	PGP public key available on web site.
~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlCXM+cACgkQVKC1jlbQAQdBIwCgzo0nlqGUJ4hGn/HKIsdhjHxR
vpMAoPJmq1WwiGC5gU1gQ3Wpq3xjC8lz
=rVpT
-----END PGP SIGNATURE-----


More information about the rsync mailing list