Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 13199 - virtual/editor and setting the EDITOR variable
Summary: virtual/editor and setting the EDITOR variable
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Seemant Kulleen (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-03 18:12 UTC by Chuck Brewer
Modified: 2003-03-16 05:34 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chuck Brewer 2003-01-03 18:12:07 UTC
please remove nano and grub from system dependencies. I understand the vi vs.
nano issue has been solved by including both on the livecd, but neither is a
system dependency. right when you get to emerge your logger, should change to
emerge your logger, editor and bootmanager. Those of us who chose other editors
and boot-managers are still being pounded with nano/grub on emerge -u system.
Comment 1 SpanKY gentoo-dev 2003-01-03 18:54:26 UTC
technically you could create your own system profile if you really have issues
with the default
Comment 2 Chuck Brewer 2003-01-03 19:35:58 UTC
I cant really think of a polite way to phase this, but I'll try. Quite a few
people managed to get vi on the install through whatever means they did, and Im
being told to change my system profile? If this really is the solution, so be
it. It must be me, but it reeks of catering and not choice. This is an
observation, not a flame, and if anyone is offended, I apologize in advance.
Comment 3 Seemant Kulleen (RETIRED) gentoo-dev 2003-01-03 20:21:07 UTC
you're absolutely correct, cbrewer, and in fact I have already raised this issue
with the other developers.  
Comment 4 Seemant Kulleen (RETIRED) gentoo-dev 2003-01-06 05:22:28 UTC
implemented both.

just remerge lilo, if you're using it, and unmerge grub.

same for your favourite editor, then unmerge nano.

do NOT forget to rsync first, though.
Comment 5 a.grahn 2003-01-13 05:00:44 UTC
But emerging another editor and unmerging nano doesn't change the EDITOR
variable in /etc/env.d/00basic. I have to do this manually. And it will get lost
with the next update of "baselayout".

Furthermore,in contrast to nano, which is installed in /bin, vim, for example,
is installed in /usr/bin. This may be dangerous during a system recovery, when
/usr/bin might be unavailable.

I think both issues should be fixed somehow.
Comment 6 SpanKY gentoo-dev 2003-01-13 10:59:46 UTC
the EDITOR=nano is not an issue, if you want something other than the defaults, set them up 
in /etc/profile or whatever your shell uses 
 
the vim in /bin/ should be filed as a new bug 
Comment 7 Seemant Kulleen (RETIRED) gentoo-dev 2003-01-13 12:39:31 UTC
yeah, it's something cbrewer and I have been discussing on IRC.  Not sure what
the best approach is just yet, but I'm open to ideas.
Comment 8 Seemant Kulleen (RETIRED) gentoo-dev 2003-01-16 08:37:01 UTC
Azarah,

is EDITOR currently just defined in /etc/rc.conf, or are there other env.d files
which contain it?
Comment 9 Martin Schlemmer (RETIRED) gentoo-dev 2003-01-19 13:34:23 UTC
Err, its in /etc/env.d/00basic, not /etc/rc.conf.  This should change ?
Comment 10 Seemant Kulleen (RETIRED) gentoo-dev 2003-02-10 08:11:43 UTC
Az: might be better to have it in rc.conf? that way you just adjust once, and then have a global setting...
Comment 11 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-16 17:49:38 UTC
Ok, will need to sorda hack it out then.  I guess /etc/profile will be a
good place to set this then (after getting it from /etc/rc.conf).
Comment 12 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-16 18:23:50 UTC
Here is a patch to /etc/profile that should set EDITOR correctly according to
/etc/rc.conf (please test etc):

---------------------------------------------------------------------------
Index: profile
===================================================================
RCS file: /home/cvsroot/gentoo-src/rc-scripts/etc/profile,v
retrieving revision 1.15
diff -u -b -B -r1.15 profile
--- profile	18 Nov 2002 19:39:22 -0000	1.15
+++ profile	16 Feb 2003 23:22:48 -0000
@@ -3,13 +3,13 @@
 
 if [ -e "/etc/profile.env" ]
 then
-	source /etc/profile.env
+	. /etc/profile.env
 fi
 
-#077 would be more secure, but 022 is generally quite realistic
+# 077 would be more secure, but 022 is generally quite realistic
 umask 022
 
-if [ `/usr/bin/whoami` = 'root' ]
+if [ "`/usr/bin/whoami`" = 'root' ]
 then
 	if [ "$SHELL" = '/bin/bash' ] || [ "$SHELL" = '/bin/sh' ]
 	then
@@ -25,6 +25,37 @@
 fi
 unset ROOTPATH
 
-if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
+if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]
+then
 	export INPUTRC="/etc/inputrc"
 fi
+
+# Extract the value of EDITOR
+get_editor() {
+	[ ! -f "$1" ] && return
+	
+	local editor="`gawk '
+		/^[[:space:]]*EDITOR[[:space:]]*=/ {
+
+			sub(/^[[:space:]]*EDITOR[[:space:]]*=/, "")
+			EDITOR = $0
+		}
+		
+		END { print EDITOR }
+	' $1`"
+
+	bash -c "eval echo $editor"
+}
+
+if [ -f /etc/rc.conf -a -n "`get_editor /etc/rc.conf`" ]
+then
+	export EDITOR="`get_editor /etc/rc.conf`"
+
+elif [ -f /etc/conf.d/basic -a -n "`get_editor /etc/conf.d/basic`" ]
+then
+	export EDITOR="`get_editor /etc/conf.d/basic`"
+
+else
+	export EDITOR="/bin/nano"
+fi
+
Comment 13 Seemant Kulleen (RETIRED) gentoo-dev 2003-02-18 06:17:56 UTC
nebuchadnezzar etc # source /etc/profile
gawk: cmd. line:7:      /etc/rc.conf
gawk: cmd. line:7:             ^ parse error
Comment 14 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-19 18:35:23 UTC
Seemant, grab it from gentoo-src, and try again?
Comment 15 Seemant Kulleen (RETIRED) gentoo-dev 2003-03-03 17:05:37 UTC
Jared, thoughts on /bin/vim (for example) ?

the vim binary is about 2M here (!!)
Comment 16 Seemant Kulleen (RETIRED) gentoo-dev 2003-03-03 17:14:54 UTC
Az, tested the profile out of cvs and it works really well :)

Comment 17 Martin Schlemmer (RETIRED) gentoo-dev 2003-03-05 14:27:30 UTC
My take is that if you need vi/vim, we should just make sure that vi is
installed to /bin, as that is small.  Vim on the other hand is not really
a minimalistic editor .....

BTW, vim and vi share /usr/bin/{ex,view} ...
Comment 18 Seemant Kulleen (RETIRED) gentoo-dev 2003-03-16 05:34:05 UTC
thanks Az -- the new baselayout looks great :)