Hi,
I digged deeper... I think I have identified the root cause.
Basically, shell set output is fragile. It may be quoted under some
condition. This needs to be accounted when writing code.
First, I realized:
$ dash
$ cd tmp
/home/osamu/tmp
$ . /etc/pbuilderrc
$ set|grep MIRRORSITE
MIRRORSITE='http://ftp.jp.debian.org/debian/'
Here you see single quotes around.
$ bash
$ cd tmp
/home/osamu/tmp
$ . /etc/pbuilderrc
$ set|grep MIRRORSITE
MIRRORSITE=http://ftp.jp.debian.org/debian/
Here no quote. I think this is what you are expecting.
load_config_file in parameter.c:71 has
asprintf(&s, "env bash -c 'set -e ; . %s; set ' 2>&1", config);
So this is always bash. You are expecting bash to drop '...' . But
that happens whenever possible but when bash worries, it keeps.
$ bash
$ FOO=foo.bar;set|fgrep FOO
FOO=foo.bar
$ FOO="foo.bar";set|fgrep FOO
FOO=foo.bar
$ FOO='foo.bar';set|fgrep FOO
FOO=foo.bar
$ FOO=foo[].bar;set|fgrep FOO
FOO='foo[].bar'
$ FOO='foo[].bar';set|fgrep FOO
FOO='foo[].bar'
$ FOO='foo[]bar';set|fgrep FOO
FOO='foo[]bar'
$ FOO='foo bar';set|fgrep FOO
FOO='foo bar'
$ FOO="foo bar";set|fgrep FOO
FOO='foo bar'
OK, now I see why my IPv6 localhost address [::0] caused erratic
problem. [] is causing it.
I think few other bugs are caused by this bash FEATURE. For example:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=704247
Space also causes to produce single quotes around.
You could write alternative strdup_unquote_as_needed() to replace many
strdup() or simply process variable output with sed script.
But it was not so simple. It seems to cause other problem if we just
use sed. (Or sed script was too complicated with escaping " and ', my
head died. )
Anyway, this needs to be fixed since this was not only causing
git-pbuilder failure but also some unexpected behaviours.
Regards,
Osamu
--- cowdancer-0.72/parameter.c 2012-05-29 06:44:29.000000000 +0900
+++ cowdancer-0.72+nmu1/parameter.c 2013-06-23 17:51:55.323160548 +0900
@@ -78,7 +78,7 @@
char* delim;
int result;
- asprintf(&s, "env bash -c 'set -e ; . %s; set ' 2>&1", config);
+ asprintf(&s, "env bash -c 'set -e ; . %s; set | sed -e \"s/\([^=]*\)=\'\(.*\)\'$/\1=\2/\"' 2>&1", config);
f=popen(s, "r");
if( NULL == f )
return -1;