diff options
author | Bryan Donlan <bdonlan@fushizen.net> | 2008-05-04 09:37:54 +0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-05-06 01:17:01 +0400 |
commit | 02b35660031e1da4036559fb928589ca8c3844bd (patch) | |
tree | c6997979e537a39b2b4d95152f4445ee9d6f01de /t/test-lib.sh | |
parent | 065096c2b558af80e670299621ff3ddc6839954c (diff) |
test-lib.sh: Add a test_set_editor function to safely set $VISUAL
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/test-lib.sh')
-rw-r--r-- | t/test-lib.sh | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index 7c2a8ba77d..d7ad13b955 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -160,6 +160,22 @@ die () { trap 'die' exit +# The semantics of the editor variables are that of invoking +# sh -c "$EDITOR \"$@\"" files ... +# +# If our trash directory contains shell metacharacters, they will be +# interpreted if we just set $EDITOR directly, so do a little dance with +# environment variables to work around this. +# +# In particular, quoting isn't enough, as the path may contain the same quote +# that we're using. +test_set_editor () { + FAKE_EDITOR="$1" + export FAKE_EDITOR + VISUAL='"$FAKE_EDITOR"' + export VISUAL +} + test_tick () { if test -z "${test_tick+set}" then |