|
From: | Moray Henderson |
Subject: | RE: [Duplicity-talk] Quotes in bash script |
Date: | Tue, 9 Nov 2010 12:04:27 +0000 |
I think I sent my previous reply from the wrong email address –
which is just as well, because it wasn’t quite right. I’ve run into this quote-removal thing a few times. The most
reliable method to get around it is to make EXC a bash array, rather than a
simple variable. If you want to preserve the wildcards when processing your for loop,
then you may also need to disable wildcard expansion – otherwise if any files
match that pattern while the loop is being processed, then name of the file
will be added to the excludes list rather than the pattern. Depending on
exactly what you want, it may work just to disable shell wildcards (“file name
globbing”) with set -f at
the beginning of the script and not use an array variable. However, this
example illustrates both: #!/bin/bash EXCLUDES="**sess_**
**civicrm/templates_c** **.no_delete**" EXC=() # Disable
file name globbing set -f for EXCLUDE
in ${EXCLUDES}; do EXC+=("--exclude"
"$EXCLUDE") done # Enable file
name globbing set +f duplicity
--encrypt-key=${ENCKEY} "address@hidden" ${DOPTS} ${SOURCE} ${DESTINATION} Referencing the array with the subscript @ expands it to all
members of the array, and when enclosed in double-quotes each element becomes
double-quoted. See Arrays in man bash for details. Moray. From: address@hidden
[mailto:address@hidden On
Behalf Of Martin Basting Hello, |
[Prev in Thread] | Current Thread | [Next in Thread] |