Thread (53 messages) flat view 53 messages, 3 authors, 2016-06-15
STALE3708d

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

From: Bryan Donlan <hidden>
Date: 2016-06-15 22:44:27
Subsystem: the rest · Maintainer: Linus Torvalds

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

Signed-off-by: Bryan Donlan <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help