shell script, rsync wrapper, space in path
I've been using this script in various forms for years now. It has a 'bad habit' as you'll see below. I think the time has come to make a significant change with the way I pass args to the main program but I'm unsure how to do that, and I'd like to understand technically why another method would work better.
Here's are just the critical snippets: Code:
RSYNCARGS="-e ssh --delete -a -v --iconv=UTF-8,UTF8-MAC --exclude /var/lib/munin \ Any suggestions would be welcome. I'd like to better understand what would be best in terms of setting the value as a string, as a command, and whether using ${RSYNCARGS} would be helpful. Cheers, -zeek |
The usual method to handle spaces in file names is to escape the space, like so:
--exclude /var/foo\ bar Note the space between the \ and bar. |
Thanks --I did try that and wound up with something like: 'rsync: link_stat "/path/to/bar" failed: No such file or directory (2)
I believe the problem is how the args are passed as a string. |
Quote:
Code:
RSYNC() { Code:
RSYNCARGS=(-e ssh --delete -a -v --iconv=UTF-8,UTF8-MAC --exclude /var/lib/munin \ |
ntubski --thanks. Turning this into a function did the trick. Important thing to remember here is including "$@" when something follows :-)
|
I think the initial approach just needed to double quote the variable:
Code:
RSYNCARGS="-e ssh --delete -a -v --iconv=UTF-8,UTF8-MAC --exclude /var/lib/munin \ |
Quote:
Code:
~/tmp$ cat ~/bin/args.sh # a useful script to understand shell arg passing Quote:
|
All times are GMT -5. The time now is 12:13 PM. |