Tux

...making Linux just a little more fun!

Quoting question

Robos [robos at muon.de]


Sat, 13 Jun 2009 20:21:08 +0200

Hi TAG,

I need some help.

I'm writing a script in which I use rsync and some functions. The test script looks like this:

#!/bin/bash
set -x
LOGDATEI=/tmp/blabla
 
backup_rsync()
{
/usr/bin/rsync -av $@
}
 
backup_rsync '/tmp/rsync-test1/Dokumente\ und\ Einstellungen' 
/tmp/rsync-test2/

This "Dokumente und Einstellungen" is the windows folder Documents and Settings. I'm stumped now, I've tried loots of combinations but can't seem to find the right combination so that the script works. The spaces in the name "Dokumente und Einstellungen" break the script. How do I have to escape/quote it?

A little help, please?

Regards and thanks in advance

Udo 'robos' Puetz


Top    Back


Kapil Hari Paranjape [kapil at imsc.res.in]


Sat, 13 Jun 2009 22:46:11 +0530

Hello,

Quotes are generally a pain!

> I'm stumped now, I've tried loots of combinations but can't seem to find  
> the right combination so that the script works. The spaces in the name  
> "Dokumente und Einstellungen" break the script. How do I have to  
> escape/quote it?

You need to put the $@ in quotes as in "$@"

Here is an example:

#!/bin/sh
 
pass_args(){
	show_args "$@"
}
 
show_args(){
	echo $1
	echo $2
}
 
pass_args 'An argument with a space' 'spaced out'

Regards,

Kapil. --


Top    Back


Robos [robos at muon.de]


Sat, 13 Jun 2009 19:47:07 +0200

Am 13.06.2009 19:16 Uhr, schrieb Kapil Hari Paranjape:

> Hello,

Hello Kapil and TAG,

> Quotes are generally a pain!

true, true...

>> I'm stumped now, I've tried loots of combinations but can't seem to find
>> the right combination so that the script works. The spaces in the name
>> "Dokumente und Einstellungen" break the script. How do I have to
>> escape/quote it?
>
> You need to put the $@ in quotes as in "$@"

Argh! I've tried to put in everything in the function call and simply didn't think about the function itself! <me stupid...>

Thanks a lot!

Regards

Udo 'robos' Puetz


Top    Back