Tiny Core Linux

Tiny Core Base => TCB Bugs => Topic started by: Len on May 05, 2013, 04:26:54 PM

Title: 4.7.6: EDITOR environment for terminal only shell
Post by: Len 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.
Title: Re: EDITOR environment for terminal only shell
Post by: roberts on May 05, 2013, 06:17:01 PM
Good suggestion. Thanks!