[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Duplicity-talk] SSH backend and shell escaping
From: |
Yves Goergen |
Subject: |
Re: [Duplicity-talk] SSH backend and shell escaping |
Date: |
Tue, 09 Dec 2014 22:55:18 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 |
Am 09.12.2014 um 22:03 schrieb Yves Goergen:
COMMON_ARGS="--archive-dir /backup
--ssh-options=\"-oIdentityFile=$SFTP_KEYFILE\""
I've tried to modify this line to avoid the nested quotes. Here's
something that doesn't scale, but what does anyway in a shell script?
COMMON_ARGS=--archive-dir\ /backup\ --ssh-options="-oIdentityFile=$SFTP_KEYFILE"
This removes the outer quotes and keeps the string as one with
backslashes before each space. Here's a surprising result:
> echo $COMMON_ARGS
--archive-dir /backup --ssh-options=-oIdentityFile=/root/.ssh/id_backup
The other quotes are completely gone. Now let me expand my example:
COMMON_ARGS=--archive-dir\ /backup\ --ssh-options="-oIdentityFile=$SFTP_KEYFILE
-oSecond=2"
> echo $COMMON_ARGS
--archive-dir /backup --ssh-options=-oIdentityFile=/root/.ssh/id_backup
-oSecond=2
Now the -oSecond=2 part is completely independent of the --ssh-options
parameter. That probably won't work for duplicity anymore I guess.
I've read somewhere "You cannot quote quotes and expect the shell to
unquote them for you." While that makes sense, I'm questioning the
purpose of bash as a scripting language for anything more complex than
simple letters and numbers. (I'm not a bash expert, and I might consider
reimplementing my backup script in some more advanced and predictable
language.)
Wouldn't it be the easiest solution to let duplicity accept the
--ssh-options parameter multiple times for each SSH option to declare? I
know that wouldn't help me now because I'm stuck at this version for the
next two years of LTS, but it may be helpful some time in the future.
It's duplicity's manpage itself that recommends using quotes:
http://duplicity.nongnu.org/duplicity.1.html
duplicity --ssh-options="-oProtocol=2 -oIdentityFile=/my/backup/id"
--
Yves Goergen
http://unclassified.de
http://dev.unclassified.de
Re: [Duplicity-talk] SSH backend and shell escaping,
Yves Goergen <=
Re: [Duplicity-talk] SSH backend and shell escaping, edgar . soldin, 2014/12/10