[wplug] escaping double quotes in enivronment variables

John Harrold jmh17 at pitt.edu
Fri Nov 26 22:03:50 EST 2004


I'm trying to set up a shell script which requires me to have double quotes
as part of an environment vairable. This is an example of what I'm trying
to do:


<script>
#! /bin/sh
export USER=user
export HOST=host.com
export RSYNC_OPTS='-av -e "ssh -2"'
export RSYNC_BIN=/usr/bin/rsync
${RSYNC_BIN} ${RSYNC_OPTS} ${USER}@${HOST}:~/test.txt .
</script>

Now when I run the script I get the following error:

rsync: -2": unknown option
rsync error: syntax or usage error (code 1) at main.c(1002)

But SYNC_OPTS is exported as:

RSYNC_OPTS="-av -e \"ssh -2\""

Now I can run the command like:

 rsync -av -e "ssh -2" user at host.com:~/test.txt .

and it works fine. So can someone tell me the correct manner to get the
double quotes escaped?

-- 
---------------------------------------------------------- 
                            | /"\                         
 john harrold               | \ / ASCII ribbon campaign   
 jmh at member.fsf.org      |  X  against HTML mail       
 the most useful idiot      | / \                         
----------------------------------------------------------
 What difference does it make to the dead, the orphans, 
 and the homeless, whether the mad destruction is brought 
 under the name of totalitarianism or the holy name of 
 liberty and democracy?
 --Gandhi
----------------------------------------------------------
  gpg --keyserver keys.indymedia.org --recv-key F65A739E
----------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://penguin.wplug.org/pipermail/wplug/attachments/20041126/f973c47a/attachment.bin


More information about the wplug mailing list