You are not logged in.

#1 2014-04-12 11:33:05

lnx
Member
Registered: 2009-11-04
Posts: 108

[solved] PATH variable in .bashrc

I added a directory with my bash scripts to the PATH variable in .bashrc:

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

PS1='[\u \W]\$ '
alias ls='ls --color'

EDITOR=nano
PATH="${PATH}:/home/s2phs/bin"

When I check the PATH variable after I logged in from the prompt, 'echo $PATH' results in

[phnx ~]$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/home/s2phs/bin

After initializing an X session, $PATH contains the /home/s2phs/bin directory twice.

[phnx ~]$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl:/home/s2phs/bin:/home/s2phs/bin

I had to switch to another PC. I installed Archlinux two days ago. I used an image (partimage) of my old home partition to copy it to this PC. I have no idea if the /home/s2phs/bin directory appeared twice in my PATH variable in the previous installation on the other PC. I only noticed it when openbox no longer autostarted some of my scripts from the /home/s2phs/bin directory and I Checked the PATH variable. Maybe the autostarting problem has nothing to do with the PATH variable.
So, why does the /home/s2phs/bin directory appear twice in the PATH variable after an X session is initialized?

Last edited by lnx (2014-04-12 13:17:05)

Offline

#2 2014-04-12 12:13:25

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: [solved] PATH variable in .bashrc

Because you put it in bashrc which is read twice by that point.  It is read when you log in to the tty, then it is read again when you start a terminal emulator (e.g. xterm) in x.

These settings should not be put in bashrc, but instead in bash_profile.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2014-04-12 13:16:41

lnx
Member
Registered: 2009-11-04
Posts: 108

Re: [solved] PATH variable in .bashrc

Yep, solved. I put in the .bashrc file because that file is used in the example on the Environment variables Environment variables archwiki page.

Offline

#4 2014-04-12 19:31:51

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [solved] PATH variable in .bashrc

lnx wrote:

I put in the .bashrc file because that file is used in the example on the Environment variables Environment variables archwiki page.


Not anymore...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB