git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t/test-lib.sh: do not trust $SHELL

From
Ramkumar Ramachandra <artagnon@gmail.com>
Date
Sep 22, 2012, 04:26 UTC
Message-ID
<CALkWK0kxmD_HJtnV0ShSdpgSjoLQHtv0=b4s=utG52zFLb2Bjg@mail.gmail.com>
In-Reply-To
<7vhaqr3t6j.fsf@alter.siamese.dyndns.org>
Hi Junio,
Junio C Hamano wrote:
> The reference to ${SHELL-/bin/sh} in the test need to be updated to
> SHELL_PATH as Peff suggested in the other subthread.

For that, the entire block needs to be moved down to come after `. GIT_BUILD_DIR="$TEST_DIRECTORY"/..`. Is this okay?

diff --git a/t/test-lib.sh b/t/test-lib.sh
index dfa86e4..2284b8b 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -15,22 +15,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see http://www.gnu.org/licenses/ .

-# if --tee was passed, write the output not only to the terminal, but
-# additionally to the file test-results/$BASENAME.out, too.
-case "$GIT_TEST_TEE_STARTED, $* " in
-done,*)
-	# do not redirect again
-	;;
-*' --tee '*|*' --va'*)
-	mkdir -p test-results
-	BASE=test-results/$(basename "$0" .sh)
-	(GIT_TEST_TEE_STARTED=done ${SHELL-sh} "$0" "$@" 2>&1;
-	 echo $? > $BASE.exit) | tee $BASE.out
-	test "$(cat $BASE.exit)" = 0
-	exit
-	;;
-esac
-
 # Keep the original TERM for say_color
 ORIGINAL_TERM=$TERM

@@ -54,6 +38,22 @@ GIT_BUILD_DIR="$TEST_DIRECTORY"/..
 . "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
 export PERL_PATH SHELL_PATH

+# if --tee was passed, write the output not only to the terminal, but
+# additionally to the file test-results/$BASENAME.out, too.
+case "$GIT_TEST_TEE_STARTED, $* " in
+done,*)
+	# do not redirect again
+	;;
+*' --tee '*|*' --va'*)
+	mkdir -p test-results
+	BASE=test-results/$(basename "$0" .sh)
+	(GIT_TEST_TEE_STARTED=done ${SHELL_PATH} "$0" "$@" 2>&1;
+	 echo $? > $BASE.exit) | tee $BASE.out
+	test "$(cat $BASE.exit)" = 0
+	exit
+	;;
+esac
+
 # For repeatability, reset the environment to known value.
 LANG=C
 LC_ALL=C
Previous: Junio C HamanoNext: Junio C Hamano
Message 28 of 37 in “How do I run tests under Valgrind?”
  1. Ramkumar RamachandraSep 17, 2012
  2. Jeff KingSep 17, 2012
  3. Ramkumar RamachandraSep 17, 2012
  4. Jeff KingSep 17, 2012
  5. Ramkumar RamachandraSep 17, 2012
  6. Jeff KingSep 17, 2012
  7. Johannes SixtSep 17, 2012
  8. Jeff KingSep 17, 2012
  9. Ramkumar RamachandraSep 17, 2012
  10. Jeff KingSep 17, 2012
  11. Ramkumar RamachandraSep 21, 2012
  12. Ramkumar RamachandraSep 21, 2012
  13. Stefano LattariniSep 21, 2012
  14. Ramkumar RamachandraSep 21, 2012
  15. Ramkumar RamachandraSep 21, 2012
  16. Jeff KingSep 21, 2012
  17. Stefano LattariniSep 22, 2012
  18. Jeff KingSep 22, 2012
  19. Stefano LattariniSep 22, 2012
  20. Junio C HamanoSep 22, 2012
  21. t/test-lib.sh: do not trust $SHELLRamkumar Ramachandra, Sep 21, 2012
  22. Jeff KingSep 21, 2012
  23. Ramkumar RamachandraSep 21, 2012
  24. Jeff KingSep 21, 2012
  25. Ramkumar RamachandraSep 21, 2012
  26. Andreas SchwabSep 21, 2012
  27. Junio C HamanoSep 21, 2012
  28. Ramkumar RamachandraSep 22, 2012
  29. Junio C HamanoSep 22, 2012
  30. Ramkumar RamachandraSep 22, 2012
  31. Ramkumar RamachandraSep 22, 2012
  32. Junio C HamanoSep 22, 2012
  33. Ramkumar RamachandraSep 26, 2012
  34. Junio C HamanoSep 21, 2012
  35. Jeff KingSep 21, 2012
  36. Andreas SchwabSep 21, 2012
  37. Jeff KingSep 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.