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:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2003 Sep 29 09:27

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] Bash question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Bash question



On Monday, Sep 29, 2003, at 08:35 US/Pacific, Jay Strauss wrote:
I want to source a script from my .bashrc. When that sourced file starts
to run I want it (the sourced file) to learn its location on the filesystem.
Normally $0 contains the full path and name of the file being run. But in a
login or su, $0 contains -bash or -su (respectively).
This isn't quite true... $0 is set properly if run as a true "subscript"
with it's own shell, like so:

/opt/myapp/bin/config

But by putting that . in the front you're running the script "inline",
which is to say in the same shell. The reason for doing this is usually
to allow the script to preserve modifications to things like environment
variables which would be lost when the subshell exits.

The only thing special about login rc scripts if the '-' at the beginning of
$0 and that they transfer control to the terminal when they're done. Other
than that, they're like any other shellscript.

-- Mitch

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



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:
EDGE Tech Corp.
For donating some give-aways for our meetings.