[wplug] escaping double quotes in enivronment variables

David Ostroske eksortso at gmail.com
Sun Nov 28 21:39:14 EST 2004


One way to fix this is to use eval after the variables are assigned:
eval "${RSYNC_BIN} ${RSYNC_OPTS} ${USER}@${HOST}:~/test.txt ."

It's dang ugly. And it's a potential risk if those vars get changed.
But it works. Make sure not to get in the habit of doing this.
-- 
David Ostroske <eksortso at gmail.com>


On Fri, 26 Nov 2004 22:03:50 -0500, John Harrold <jmh17 at pitt.edu> wrote:
> 
> 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
> ----------------------------------------------------------


More information about the wplug mailing list