liug <liug@mama.indstate.edu> wrote:
Jens H Jorgensen <> jhj@remove-nospam-videk.com> > wrote:
On the console the shell is run directly from the kernel image(see below)
sounds like it is a “bug” with the kernel image > > it doesn’t
honor your /etc/profile or .profile.
Maybe at that time, kernel images can’t see filesystem yet?
No, it isn’t a bug. It is normal expected shell initialization behaviour.
Shell initialization rules:
If the shell is a login shell – i.e. if argv[0][0] == ‘-’ – then
the shell will look for /etc/profile and will interpret the commands
there if the file exists (and is readable)
the shell will look for $HOME/.profile and will interpret the commands
there if the file exists (and is readable)
For all shells, the shell will check if the ENV environment variable is
set, if so, and if the file $ENV exists and is readable, the shell
will interpret the commands there. (Traditionally this file is
called $HOME/.rc, e.g. $HOME/.kshrc or $HOME/.shrc .)
(The above is the case for bourne/korn shells (ksh which is pdksh, a
public-domain implementation of the korn shell). For other shells,
e.g. itcsh, csh, esh, fesh, the rules may be different.)
What this means: environment variables are inherited, other settings
(such as aliases, key-bindings) are not. You should put environment
variable settings in the .profile, other aliases and commands into
the $ENV file. That way, if you start a sub-shell, you will still get
those settings.
Some things you could do:
– try and force the shell to be a login shell. I don’t think there
is any way to specify the argv[0] for stuff started in the boot script,
but you could write a small starter program in C that does this manipulation
for you. Or, put a (procmgr) symlink from -ksh to /bin/ksh somewhere that
is in the search path.
– login properly
– export ENV and any other environment variables before running the
shell, e.g. [+session] ENV=/home/root/.kshrc /bin/ksh
– manually source (read in and interpret) your profile, e.g.:
at the prompt, just type
. /etc/profile
-David
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.