From nobody@FreeBSD.org  Fri Apr  4 15:14:23 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 1F17E106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Apr 2008 15:14:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 175588FC1D
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Apr 2008 15:14:23 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m34FEE8g063831
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 4 Apr 2008 15:14:14 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m34FEE4q063830;
	Fri, 4 Apr 2008 15:14:14 GMT
	(envelope-from nobody)
Message-Id: <200804041514.m34FEE4q063830@www.freebsd.org>
Date: Fri, 4 Apr 2008 15:14:14 GMT
From: Matthijs Kooijman <matthijs@stdin.nl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Unable to override EDITOR in /etc/profile due to default dot.profile
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         122445
>Category:       conf
>Synopsis:       Unable to override EDITOR in /etc/profile due to default dot.profile
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 04 15:20:02 UTC 2008
>Closed-Date:    
>Last-Modified:  Fri Apr 04 22:01:10 UTC 2008
>Originator:     Matthijs Kooijman
>Release:        6.2
>Organization:
>Environment:
>Description:
The default .profile for new users (/usr/share/skel/dot.profile) contains
unconditional setting of the EDITOR environment variable:

  EDITOR=vi;      export EDITOR

I have a need to change the default editor on a systemwide basis, while
still allowing individual users to override the EDITOR setting.  I
implemented this by putting   

  EDITOR=vim;      export EDITOR

in /etc/profile. However, on each login, bash (and probably sh as well)
first reads /etc/profile and then overrides the value of EDITOR with
the one from ~/.profile (as should happen).

However, this leaves me with no way to effectively set a systemwide
default EDITOR, apart from going into each user's .profile and removing
the offending lines.

Obviously, this problem could be prevented by changing dot.profile before creating users, but I would like to see a more out-of-the box solution.

I see two options. First, one could replace the offending line in
dot.profile with something like 

  [ -z "$EDITOR" ] && EDITOR=vi
  export EDITOR

This only sets EDITOR to vi if no system wide default was given. This
solves the problem, and when nothing is changed in /etc/profile, behaviour
is unchanged. It might be not so clear to users, however, that want to
change their editor.

Another option would be to set the vi default option in /etc/profile in
the first place. By adding a single line to /etc/profile:

  EDITOR=vi; export EDITOR

and replacing the offending line in dot.profile by a useful comment:

  # Uncomment this to change your default editor
  #EDITOR=vi; export EDITOR

the problem is also solved, and again, the out-of-the-box behaviour is
the same (AFAICS).

Additionally, dot.profile contains two more lines that set defaults for
the PAGER and BLOCKSIZE options. The same problem and solution applies
to these options, though they are less likely to bite anyone, I guess.

Gr.

Matthijs
>How-To-Repeat:

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
