Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 14994 - ksh -l (login shell mode) could not load /etc/profile because of 'source /etc/profile.env' works for bash/zsh/... only
Summary: ksh -l (login shell mode) could not load /etc/profile because of 'source /etc...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-02 13:30 UTC by Oleg Cherkasov
Modified: 2003-04-06 11:02 UTC (History)
0 users

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 Oleg Cherkasov 2003-02-02 13:30:18 UTC
Korn shell in login mode says: 
 
$ ksh -l 
ksh: /etc/profile[7]: source: not found 
 
The line 7 is: 
 
source /etc/profile.env 
 
it works for Bash/zsh but not for vanilla ksh.  Guess it should be replaced by: 
 
. /etc/profile.env 
 

Reproducible: Always
Steps to Reproduce:
1. run KornShell in login mode as ksh -l 
2. see error message from /etc/profile 
Actual Results:  
/etc/profile will be not used by ksh, but it still runs all right. 

Expected Results:  
obviously I expect no error messages.
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2003-02-16 18:29:37 UTC
Please check if the following patch to /etc/profile works with ksh:

------------------------------------------------------------------------
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 2 Oleg Cherkasov 2003-02-23 12:34:31 UTC
It looks good, the patch works fine to me.  Thanks! 
Comment 3 Martin Schlemmer (RETIRED) gentoo-dev 2003-04-06 11:02:02 UTC
Fixed in baselayout-1.8.6.4.