# [RFC/PATCH] consistently try VISUAL, EDITOR and vi in this order.

2 messages from 2006-07-03 to 2006-07-03. Participants: Junio C Hamano, Jakub Narebski.
Thread: https://gitlist.dev/t/4746

## Junio C Hamano, 2006-07-03 02:47

Subject: [RFC/PATCH] consistently try VISUAL, EDITOR and vi in this order.
Message-ID: <7vmzbrv1yc.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vmzbrv1yc.fsf%40assigned-by-dhcp.cox.net

```
git grep -e VISUAL -e EDITOR revealed this inconsistency.  All
other commands seem to check VISUAL and then EDITOR as they should.

---
diff --git a/git-send-email.perl b/git-send-email.perl
index c5d9e73..7b81962 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -222,8 +256,7 @@ GIT: for the patch you are writing.
 EOT
 	close(C);
 
-	my $editor = $ENV{EDITOR};
-	$editor = 'vi' unless defined $editor;
+	my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
 	system($editor, $compose_filename);
 
 	open(C2,">",$compose_filename . ".final")

```

## Jakub Narebski, 2006-07-03 09:24

Subject: Re: [RFC/PATCH] consistently try VISUAL, EDITOR and vi in this order.
Message-ID: <e8anmn$ufp$1@sea.gmane.org>
URL: https://gitlist.dev/e/e8anmn%24ufp%241%40sea.gmane.org
In-Reply-To: <7vmzbrv1yc.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> git grep -e VISUAL -e EDITOR revealed this inconsistency.  All
> other commands seem to check VISUAL and then EDITOR as they should.
> 

> +     my $editor = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
>       system($editor, $compose_filename);

Shouldn't we check if we are in visual (non CLI-only) environment,
like X-Window, MS Windows or MacOS X, before trying to use VISUAL?
How other parts solve it? </me checks> Ah, we use VISUAL unconditionally,
at least in scripts...

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```
