WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: 4.7.6: EDITOR environment for terminal only shell  (Read 2731 times)

Offline Len

  • Newbie
  • *
  • Posts: 14
4.7.6: EDITOR environment for terminal only shell
« on: May 05, 2013, 04:26:54 PM »
On a TCL system which has X Windows installed, if one were to drop to back to the terminal (exit X Windows), or ssh into the system from a non X Windows environment, the EDITOR environment variable is still set to editor (a non terminal editor).  Executing system commands that rely on the EDITOR environment variable fail (e.g. crontab -e).

I propose 2 minor changes to address this issue.

First, to replace line 16 in .profile (`which editor > /dev/null` && EDITOR=editor || EDITOR=vi) with the following:
   EDITOR=vi
Second, to insert line 3 in .ashrc
   if [ -n "$DISPLAY" ]
   then
      `which editor > /dev/null` && EDITOR=editor || EDITOR=vi
   else
      EDITOR=vi
   fi
   export EDITOR
The above change to .ashrc will get sourced by .profile and in the case that .profile is originally sourced (depends on how the shell is invoked).  Then the environment variable DISPLAY is checked first before trying to set to editor and falls back to vi.

I edited the subject to include the latest version in which I discovered this issue.  The problem was also present in (at least) 4.7.5 and 4.7.4.
« Last Edit: May 06, 2013, 02:32:38 PM by Len »

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: EDITOR environment for terminal only shell
« Reply #1 on: May 05, 2013, 06:17:01 PM »
Good suggestion. Thanks!
10+ Years Contributing to Linux Open Source Projects.