t5532: use write_script

The recent cleanup in b7cbbff switched t5532's use of backticks to $(). This matches our normal shell style, which is good. But it also breaks the test on Solaris, where /bin/sh does not understand $(). Our normal shell style assumes a modern-ish shell which knows about $(). However, some tests create small helper scripts and just write "#!/bin/sh" into them. These scripts either need to go back to using backticks, or they need to respect $SHELL_PATH. The easiest way to do the latter is to use write_script. While we're at it, let's also stick the script creation inside a test_expect block (our usual style), and split the perl snippet into its own script (to prevent quoting madness). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Apr 9, 2016 at 17:04 UTC ca386ee177dac34a8a4721d546d05e4c6f96417b
1 file changed +12 -9
t/t5532-fetch-proxy.sh
+12 -9
@@ -12,10 +12,8 @@ test_expect_success 'setup remote repo' '
12 )
13 '
14
15 -cat >proxy <<'EOF'
16 -#!/bin/sh
17 -echo >&2 "proxying for $*"
18 -cmd=$("$PERL_PATH" -e '
15 +test_expect_success 'setup proxy script' '
16 + write_script proxy-get-cmd "$PERL_PATH" <<-\EOF &&
17 read(STDIN, $buf, 4);
18 my $n = hex($buf) - 4;
19 read(STDIN, $buf, $n);
@@ -23,11 +21,16 @@ cmd=$("$PERL_PATH" -e '
21 # drop absolute-path on repo name
22 $cmd =~ s{ /}{ };
23 print $cmd;
26 -')
27 -echo >&2 "Running '$cmd'"
28 -exec $cmd
29 -EOF
30 -chmod +x proxy
24 + EOF
25 +
26 + write_script proxy <<-\EOF
27 + echo >&2 "proxying for $*"
28 + cmd=$(./proxy-get-cmd)
29 + echo >&2 "Running $cmd"
30 + exec $cmd
31 + EOF
32 +'
33 +
34 test_expect_success 'setup local repo' '
35 git remote add fake git://example.com/remote &&
36 git config core.gitproxy ./proxy