[PATCH 5/8] test-lib.sh: Add a test_set_editor function to safely set $VISUAL

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Cc: Johannes Sixt <j.sixt@...>, Adam Roben <aroben@...>, <gitster@...>, Bryan Donlan <bdonlan@...>
Date: Tuesday, April 8, 2008 - 9:30 pm

In particular, this function correctly handles cases where the pwd contains
spaces, quotes, and other troublesome metacharacters.

Signed-off-by: Bryan Donlan <bdonlan@fushizen.net>
---
 t/test-lib.sh |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 17d4bc0..6f43376 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -160,6 +160,15 @@ die () {
 
 trap 'die' exit
 
+test_set_editor () {
+	# If the editor path contains a quote, just using VISUAL='"path"' isn't
+	# enough.
+	FAKE_EDITOR="$1"
+	export FAKE_EDITOR
+	VISUAL='"$FAKE_EDITOR"'
+	export VISUAL
+}
+
 test_tick () {
 	if test -z "${test_tick+set}"
 	then
-- 
1.5.5.8.gbbd98

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 4/8] test-lib.sh: Fix some missing path quoting, Bryan Donlan, (Tue Apr 8, 9:30 pm)
[PATCH 5/8] test-lib.sh: Add a test_set_editor function to s..., Bryan Donlan, (Tue Apr 8, 9:30 pm)
[PATCH 7/8] Use test_set_editor in t9001-send-email.sh, Bryan Donlan, (Tue Apr 8, 9:30 pm)