help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Query on _evalfile function in bash-4.3/builtins/evalfile.c


From: Vijay Karode
Subject: [Help-bash] Query on _evalfile function in bash-4.3/builtins/evalfile.c
Date: Fri, 20 Feb 2015 08:15:02 +0530

Hi All,

BASH is a wonderful shell and you guys are doing a wonderful job
maintaining it.Hats Off to you all.

>From past few days I was getting curious as of how the shell actually
works.So,started digging into the source code.Shell obviously does loads of
things,but one of the things which it does after login program has given
the control is to load the user specific profile file like
.bash_profile.This is obviously not done via a fork and exec as we want the
env to be set up in the parent and not in subshell.
The builtin source command also does the same thing.It affects the current
shell.

While going through the source code in file shell.c,i found a function call
like

maybe_execute_file ("~/.bash_profile", 1);

This function gives call to _evalfile function,which as i understood copies
the entire file into one string and tries to process/execute it.
But,I am unable to understand as of how it does it.Which function exactly
breaks the whole string into individual "name=value" chunks and pushes it
into the current environment.Is it done via storing it in static memory or
by executing it internally via some command?


I also happen to look at the source code of source builtin command.Even it
internally gives call to _evalfile.

Kindly correct me if I am wrong,and some guidance will be helpful.
I really want to understand the BASH shell's working.


Thanks in advance,
Regards,
Vijay Karode


reply via email to

[Prev in Thread] Current Thread [Next in Thread]