l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
October 20: Web Application Hacking: How to Make and Break Security on the Web
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2001 Dec 30 17:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] persistant aliases under bash?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] persistant aliases under bash?



On Tue, Mar 27, 2001 at 12:23:12PM -0800, Peter Jay Salzman wrote:
> On Tue 27 Mar 01, 11:55 AM, Micah Cowan said: 
> > 
> > That's completely non-sequitur.  /etc/profile isn't loaded in xterm.
> > /etc/bashrc is.  So try /exactly/ the same trick with /etc/bashrc,
> > don't bother to source it (but do save it) and open a new xterm.
>  
> micah, you're causing me to lose my hair.  please read carefully.
> 
> i want my aliases in both console and X.   i care more about console since i
> spend 75% of my time in a non-graphical environment.  the few times my
> computer is in X is mostly playing quake.  but i WOULD like my aliases under
> X as well.

Your turn to read carefully.

Invoking X does not invoke a subshell - when you open an X term, this
is not a subshell, but an entirely /new/ session (but not a login
session) - thus sourcing a file before running X has no effect.
/etc/profile and /etc/.bash_profile never get sourced from an X term
(unless you do so explicitly.)

> 
> > This is completely useless behavior for me, so here is the complete
> > contents of my ~/.bash_profile:
>  
> > # .bash_profile
> > if [ -f ~/.bashrc ]
> > then
> >     . ~/.bashrc
> > fi
> 
> this is a /rotten/ way of doing things.  on an aesthetic level, you've
> completely demolished the division between startup files for graphical and
> text environments.  ugly.

This is a /standard/ way of doing things.  And there was never meant
to be a division between graphical and text environments for these
files - the division remains between login- and non-login-sessions.
You want something to apply to your /graphical/ environments, it
belongs in .xinitrc or .xsession.

> 
> on a practical level, doing this would cause errors for me because i use
> xmodmaps in my bashrc.

This should be in your .xinitrc or equivalent.

But even if you hate the above method (despite the fact that it is
standard practice), your solution is simple - create a ~/.shared.sh
file and source it from within both your ~/.bashrc and
~/.bash_profile.  Place information which you wish to have in both
within ~/.shared.sh

> 
> on another practical level, i define my PATH sparsely under console, and add
> things like /usr/X11/bin ONLY when i'm in a graphical environment.  this
> speeds up finding executables.   so i /like/ the distinction between the
> graphical and console startup files.

Again, ~/.bashrc wasn't meant to serve this purpose.  There are
certainly cases where ~/.bashrc will be sourced on the console - any
session which isn't invoked from "login".

> 
> pete
> 
> ps- currently, i have my aliases in /etc/bash.aliases which gets sourced
> both by profile and bashrc.   but i'm still interested in my original
> question.
> 
> pps- you're still wrong (about the persistance of aliases into subshells),
> but you don't know it because you concentrated on my typo between profile and
> bashrc.  follow these instructions, please, for the sake of my sanity.
> 
> 1. kill X
> 2. at the console, type alias ff='df -h'
> 3. start X.  launch an xterm.
> 4. type "ff".
> 5. see the lovely error message.

As I mentioned: nonsequitur.  X is not a subshell.  It removes your
environment variables and sets its own, before loading programs.

However, I'm /still/ wrong (about subshells).  The /correct/ way of
proving this is:

1. At the console, type alias ff='df -h'
2. Type 'bash'
3. Type alias ff
4. Type exit.

Micah


LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!