Skip to content

Commit e8189ee

Browse files
Tarmigan Caseboltgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Tarmigan Casebolt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd0a8c2 commit e8189ee

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

t/t5560-http-backend-noserver.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ run_backend() {
1414
}
1515

1616
GET() {
17-
REQUEST_METHOD="GET" \
17+
export REQUEST_METHOD="GET" &&
1818
run_backend "/repo.git/$1" &&
19+
unset REQUEST_METHOD &&
1920
if ! grep "Status" act.out >act
2021
then
2122
printf "Status: 200 OK\r\n" >act
@@ -25,9 +26,11 @@ GET() {
2526
}
2627

2728
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" &&
3031
run_backend "/repo.git/$1" "$2" &&
32+
unset REQUEST_METHOD &&
33+
unset CONTENT_TYPE &&
3134
if ! grep "Status" act.out >act
3235
then
3336
printf "Status: 200 OK\r\n" >act
@@ -43,13 +46,15 @@ log_div() {
4346
. "$TEST_DIRECTORY"/t556x_common
4447

4548
expect_aliased() {
49+
export REQUEST_METHOD="GET" &&
4650
if test $1 = 0; then
47-
REQUEST_METHOD=GET run_backend "$2"
51+
run_backend "$2"
4852
else
49-
REQUEST_METHOD=GET run_backend "$2" &&
53+
run_backend "$2" &&
5054
echo "fatal: '$2': aliased" >exp.err &&
5155
test_cmp exp.err act.err
5256
fi
57+
unset REQUEST_METHOD
5358
}
5459

5560
test_expect_success 'http-backend blocks bad PATH_INFO' '

0 commit comments

Comments
 (0)