Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Apr 2008 15:14:14 GMT
From:      Matthijs Kooijman <matthijs@stdin.nl>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   conf/122445: Unable to override EDITOR in /etc/profile due to default dot.profile
Message-ID:  <200804041514.m34FEE4q063830@www.freebsd.org>
Resent-Message-ID: <200804041520.m34FK2bA045879@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:
>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200804041514.m34FEE4q063830>