Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
/etc/profile
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
qxtr01
n00b
n00b


Joined: 04 Nov 2008
Posts: 47

PostPosted: Tue Feb 03, 2009 7:28 pm    Post subject: /etc/profile Reply with quote

i just edited my /etc/profile file. now it just contains this:

Code:

if [[ -e /etc/profile.env ]]; then

   source /etc/profile.env

fi

if [[ "$USER" = root ]]; then

   PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}"

else

   PATH="/usr/local/bin:/usr/bin:/bin:${PATH}"

fi


what do you think? did i remove too much?
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Tue Feb 03, 2009 7:35 pm    Post subject: Re: /etc/profile Reply with quote

qxtr01 wrote:
i just edited my /etc/profile file. now it just contains this:

Code:

if [[ -e /etc/profile.env ]]; then

   source /etc/profile.env

fi

if [[ "$USER" = root ]]; then

   PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}"

else

   PATH="/usr/local/bin:/usr/bin:/bin:${PATH}"

fi


what do you think? did i remove too much?


Most stuff in that file is commented anyway, and half of the rest is devoted to the creation of a propmp, so it's not exactly critical stuff (except for the env stuff). However, just on a quick glance I can tell you that you're missing the EDITOR and PAGER exports, which can be quite annoying if not problematic sometimes. Some programs might assume that these will be set.

Note that I haven't checked too deep. There might be some other problem that I don't see right now.
Back to top
View user's profile Send private message
qxtr01
n00b
n00b


Joined: 04 Nov 2008
Posts: 47

PostPosted: Tue Feb 03, 2009 7:45 pm    Post subject: Reply with quote

in particular i'm a bit worried of not having put "export PATH", but it seems to work despite of this...
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Tue Feb 03, 2009 8:10 pm    Post subject: Reply with quote

qxtr01 wrote:
in particular i'm a bit worried of not having put "export PATH", but it seems to work despite of this...


That means that $PATH won't be accessible by subsequently run programs. For example, if a given program that you are running under on your command line needs to use $PATH for something, it will find that the variable doesn't exist.

The shells, however, will continue working as always, because bash always sources /etc/profile on each new instance that you open (you can read about all the bash init files on it's man page, section "INVOCATION").

Anyway, what's the point of all that "cleaning"? As said, most stuff in there is either a comment (which is not parsed) or a variable declaration or export, which is quite fast to run. You are not going to gain any time by doing that.
Back to top
View user's profile Send private message
qxtr01
n00b
n00b


Joined: 04 Nov 2008
Posts: 47

PostPosted: Tue Feb 03, 2009 8:26 pm    Post subject: Reply with quote

i'm not editing /etc/profile for performance-related reasons, but for understanding bash in more depth.

anyway, i didn't understand the PATH thing.

in an xterm i can do:
Code:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3


if i create the following test bash script:
Code:
#!/bin/bash
echo $PATH

and then run it, i obtain the same result.
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10315
Location: Córdoba (Spain)

PostPosted: Wed Feb 04, 2009 8:48 am    Post subject: Reply with quote

qxtr01 wrote:
i'm not editing /etc/profile for performance-related reasons, but for understanding bash in more depth.

anyway, i didn't understand the PATH thing.

in an xterm i can do:
Code:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3


if i create the following test bash script:
Code:
#!/bin/bash
echo $PATH

and then run it, i obtain the same result.


Bash itself is a bit creepy about how it does the things. However, you can try a simple C program, for example:

Code:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  char *env=getenv("MYVAR");
  printf("MYVAR=\"%s\"\n",env);
}


If you compile and run it the first time you are going to get this:

Code:
$ gcc test.c -o test
$ ./test
PATH="(null)"


It was to be expected since that var doesn't exist. Now, if we play a bit with bash we will see how vars are threated:

Code:

# this way it works, this is why we can also do USE="whatever" emerge whatever-else
$ MYVAR=C ./test
MYVAR="C"

# this doesn't work, because MYVAR is declared, but not marked to be exported
$ MYVAR=C
$ ./test
MYVAR="(null)"

# but this time it will work again
$ export MYVAR=C
$ ./test
MYVAR="C"


I hope it cleared the thing abit for you.
Back to top
View user's profile Send private message
ok
Guru
Guru


Joined: 11 Jul 2006
Posts: 390
Location: germany

PostPosted: Wed Feb 04, 2009 8:33 pm    Post subject: Reply with quote

qxtr01 wrote:
i'm not editing /etc/profile for performance-related reasons, but for understanding bash in more depth.

anyway, i didn't understand the PATH thing.

in an xterm i can do:
Code:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3


if i create the following test bash script:
Code:
#!/bin/bash
echo $PATH

and then run it, i obtain the same result.

What is the output of
Code:
$ export | grep PATH
?
Back to top
View user's profile Send private message
qxtr01
n00b
n00b


Joined: 04 Nov 2008
Posts: 47

PostPosted: Wed Feb 04, 2009 8:52 pm    Post subject: Reply with quote

Code:
$ export | grep PATH
declare -x INFOPATH="/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.19/info:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/info"
declare -x MANPATH="/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.19/man:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/man:/usr/lib/php5/man/"
declare -x PATH="/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3"
declare -x ROOTPATH="/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3"
declare -x WINDOWPATH="7
Back to top
View user's profile Send private message
ok
Guru
Guru


Joined: 11 Jul 2006
Posts: 390
Location: germany

PostPosted: Wed Feb 04, 2009 9:27 pm    Post subject: Reply with quote

Code:
if [[ -e /etc/profile.env ]]; then

   source /etc/profile.env

fi

Could it be that PATH will be exported in /etc/profile.env?
# grep PATH /etc/profile.env?
man export: ... export - set the export attribute for variables...

The variable is still marked as exported if the value changed. If you want to remove the export attribute look at '# help export'.
Back to top
View user's profile Send private message
qxtr01
n00b
n00b


Joined: 04 Nov 2008
Posts: 47

PostPosted: Thu Feb 05, 2009 10:21 am    Post subject: Reply with quote

Code:
$ grep PATH /etc/profile.env
export INFOPATH='/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.19/info:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/info'
export MANPATH='/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.19/man:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/man:/usr/lib/php5/man/'
export PATH='/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3'
export ROOTPATH='/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3'
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum