|
From: | Kenneth Loafman |
Subject: | Re: [Duplicity-talk] SSH backend and shell escaping |
Date: | Tue, 9 Dec 2014 16:23:28 -0600 |
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
_______________________________________________
Duplicity-talk mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/duplicity-talk
[Prev in Thread] | Current Thread | [Next in Thread] |