{"thread":{"id":"59506","subject":"[PATCH] t5563: prevent \"ambiguous redirect\"","startedAt":"2023-03-31T06:52:42Z","lastAt":"2023-03-31T15:40:13Z","messageCount":2,"participants":["Johannes Schindelin via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"474497","messageId":"pull.1507.git.1680245525637.gitgitgadget@gmail.com","threadId":"59506","inReplyTo":null,"subject":"[PATCH] t5563: prevent \"ambiguous redirect\"","fromName":"Johannes Schindelin via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-03-31T06:52:05Z","receivedAt":"2023-03-31T06:52:42Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"From: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nWhen I ran this test using `TEST_SHELL_PATH=/bin/bash` in my Ubuntu\nsetup (where Bash is at version 5.0.17(1)-release), I was greeted with\nthis error message:\n\n\t./test-lib.sh: line 1072: $CHALLENGE: ambiguous redirect\n\nThis commit fixes that error by quoting the `CHALLENGE` variable (which\nhas as value a path containing spaces), and by avoiding to cuddle the\nempty string parameter in the `printf` call with the redirect character\n(in fact, the `printf ''>$CHALLENGE` is removed because the next line\noverwrites the file anyway because it _also_ uses a single `>` to\nredirect the output).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n    t5563: prevent \"ambiguous redirect\"\n    \n    I ran into this issue while running the tests with\n    TEST_SHELL_PATH=/bin/bash.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1507%2Fdscho%2Ffix-ambiguous-redirect-in-t5563-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1507/dscho/fix-ambiguous-redirect-in-t5563-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1507\n\n t/t5563-simple-http-auth.sh | 26 ++++++++++++--------------\n 1 file changed, 12 insertions(+), 14 deletions(-)\n\ndiff --git a/t/t5563-simple-http-auth.sh b/t/t5563-simple-http-auth.sh\nindex ccf7e54b073..f45a43b4b5e 100755\n--- a/t/t5563-simple-http-auth.sh\n+++ b/t/t5563-simple-http-auth.sh\n@@ -252,15 +252,14 @@ test_expect_success 'access using basic auth with wwwauth header empty continuat\n \n \t# Note that leading and trailing whitespace is important to correctly\n \t# simulate a continuation/folded header.\n-\tprintf \"\">$CHALLENGE &&\n-\tprintf \"WWW-Authenticate: FooBar param1=\\\"value1\\\"\\r\\n\" >$CHALLENGE &&\n-\tprintf \" \\r\\n\" >>$CHALLENGE &&\n-\tprintf \" param2=\\\"value2\\\"\\r\\n\" >>$CHALLENGE &&\n-\tprintf \"WWW-Authenticate: Bearer authorize_uri=\\\"id.example.com\\\"\\r\\n\" >>$CHALLENGE &&\n-\tprintf \" p=1\\r\\n\" >>$CHALLENGE &&\n-\tprintf \" \\r\\n\" >>$CHALLENGE &&\n-\tprintf \" q=0\\r\\n\" >>$CHALLENGE &&\n-\tprintf \"WWW-Authenticate: Basic realm=\\\"example.com\\\"\\r\\n\" >>$CHALLENGE &&\n+\tprintf \"WWW-Authenticate: FooBar param1=\\\"value1\\\"\\r\\n\" >\"$CHALLENGE\" &&\n+\tprintf \" \\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \" param2=\\\"value2\\\"\\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \"WWW-Authenticate: Bearer authorize_uri=\\\"id.example.com\\\"\\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \" p=1\\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \" \\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \" q=0\\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \"WWW-Authenticate: Basic realm=\\\"example.com\\\"\\r\\n\" >>\"$CHALLENGE\" &&\n \n \ttest_config_global credential.helper test-helper &&\n \tgit ls-remote \"$HTTPD_URL/custom_auth/repo.git\" &&\n@@ -298,11 +297,10 @@ test_expect_success 'access using basic auth with wwwauth header mixed line-endi\n \n \t# Note that leading and trailing whitespace is important to correctly\n \t# simulate a continuation/folded header.\n-\tprintf \"\">$CHALLENGE &&\n-\tprintf \"WWW-Authenticate: FooBar param1=\\\"value1\\\"\\r\\n\" >$CHALLENGE &&\n-\tprintf \" \\r\\n\" >>$CHALLENGE &&\n-\tprintf \"\\tparam2=\\\"value2\\\"\\r\\n\" >>$CHALLENGE &&\n-\tprintf \"WWW-Authenticate: Basic realm=\\\"example.com\\\"\" >>$CHALLENGE &&\n+\tprintf \"WWW-Authenticate: FooBar param1=\\\"value1\\\"\\r\\n\" >\"$CHALLENGE\" &&\n+\tprintf \" \\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \"\\tparam2=\\\"value2\\\"\\r\\n\" >>\"$CHALLENGE\" &&\n+\tprintf \"WWW-Authenticate: Basic realm=\\\"example.com\\\"\" >>\"$CHALLENGE\" &&\n \n \ttest_config_global credential.helper test-helper &&\n \tgit ls-remote \"$HTTPD_URL/custom_auth/repo.git\" &&\n\nbase-commit: 5f2117b24f568ecc789c677748d70ccd538b16ba\n-- \ngitgitgadget\n"},{"id":"474507","messageId":"xmqq7cuxhqus.fsf@gitster.g","threadId":"59506","inReplyTo":"pull.1507.git.1680245525637.gitgitgadget@gmail.com","subject":"Re: [PATCH] t5563: prevent \"ambiguous redirect\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-03-31T15:39:55Z","receivedAt":"2023-03-31T15:40:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Johannes Schindelin via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> (in fact, the `printf ''>$CHALLENGE` is removed because the next line\n> overwrites the file anyway because it _also_ uses a single `>` to\n> redirect the output).\n\nGood eyes. I also wondered what that empty printf was doing.  While\nI suspect the original intention was to start from an empty file and\nkeep appending contents with any meaning so that the redirection on\nsubsequent lines would look identical, I do not think it is\nnecessary in this case, primarily because it is unlikely that any\nfuture change will swap the first line with any subsequent lines.\n\nThanks for spotting.  I was hoping that we could soon retire the\n\"quote the redirection target if it has parameter substitution to\nhelp older bash\" rule in our coding guidelines, but this example\nshows that the world is not quite ready yet.\n\n"}]}