Test t5560: Fix test when run with dash
A command invocation preceded by variable assignments, i.e. VAR1=VAL1 VAR2=VAL2 ... command args are implemented by dash and ksh in such a way not to export these variables, and keep the values after the command finishes, when the command is a shell function. POSIX.1 "2.9.5 Function Definition Command" specifies this behaviour. Many shells however treat this construct the same way as they are calling external commands. They export the variables during the duration of command, and resets their values after command returns. The test relied on the behaviour of the latter kind. Reported-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Tarmigan Casebolt <tarmigan+git@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Tarmigan Casebolt committed
Jan 14, 2010 at 22:44 UTC
e8189ee90e65094dd46a9e4ee6455d9efa90fa76
1 file changed
+10
-5
t/t5560-http-backend-noserver.sh
+10
-5
@@ -14,8 +14,9 @@ run_backend() {
14
}
15
16
GET() {
17
- REQUEST_METHOD="GET" \
17
+ export REQUEST_METHOD="GET" &&
18
run_backend "/repo.git/$1" &&
19
+ unset REQUEST_METHOD &&
20
if ! grep "Status" act.out >act
21
then
22
printf "Status: 200 OK\r\n" >act
@@ -25,9 +26,11 @@ GET() {
26
}
27
28
POST() {
28
- REQUEST_METHOD="POST" \
29
- CONTENT_TYPE="application/x-$1-request" \
29
+ export REQUEST_METHOD="POST" &&
30
+ export CONTENT_TYPE="application/x-$1-request" &&
31
run_backend "/repo.git/$1" "$2" &&
32
+ unset REQUEST_METHOD &&
33
+ unset CONTENT_TYPE &&
34
if ! grep "Status" act.out >act
35
then
36
printf "Status: 200 OK\r\n" >act
@@ -43,13 +46,15 @@ log_div() {
46
. "$TEST_DIRECTORY"/t556x_common
47
48
expect_aliased() {
49
+ export REQUEST_METHOD="GET" &&
50
if test $1 = 0; then
47
- REQUEST_METHOD=GET run_backend "$2"
51
+ run_backend "$2"
52
else
49
- REQUEST_METHOD=GET run_backend "$2" &&
53
+ run_backend "$2" &&
54
echo "fatal: '$2': aliased" >exp.err &&
55
test_cmp exp.err act.err
56
fi
57
+ unset REQUEST_METHOD
58
}
59
60
test_expect_success 'http-backend blocks bad PATH_INFO' '