Bug 122445 - Unable to override EDITOR in /etc/profile due to default dot.profile
Summary: Unable to override EDITOR in /etc/profile due to default dot.profile
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-04 16:20 UTC by Matthijs Kooijman
Modified: 2017-12-31 22:37 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthijs Kooijman 2008-04-04 16:20:02 UTC
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
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:17 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped