LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   working of bash shell (https://www.linuxquestions.org/questions/linux-general-1/working-of-bash-shell-774916/)

mohit_parihar 12-11-2009 04:46 AM

working of bash shell
 
can any one tell me how does bash help in executing the command echo and kill.how does the shell checks whether the command is builtin command or not. plz tell the complete procedure for both commands.

catkin 12-11-2009 04:58 AM

Without inspecting the bash source code it's hard to know but it probably has a list of its own built-ins and, when it is given a command to execute without a path (without a leading ~, ./ or /) it consults that list.

Aquarius_Girl 12-11-2009 05:20 AM

Quote:

Originally Posted by mohit_parihar
can any one tell me how does bash help in executing the command echo and kill

Bash shell forks a child process in order to execute any command including 'echo' or 'kill' whatever.

The child process i.e. 'echo' or 'kill' whatever dies automatically when it completes its execution !

I see u are posting all your assignment questions one by one for us to solve ?????????

Aquarius_Girl 12-11-2009 05:28 AM

Try reading this:

http://tldp.org/LDP/abs/html/internal.html

catkin 12-11-2009 08:17 AM

Quote:

Originally Posted by anishakaul (Post 3787634)
Bash shell forks a child process in order to execute any command including 'echo' or 'kill' whatever.

The child process i.e. 'echo' or 'kill' whatever dies automatically when it completes its execution !

I see u are posting all your assignment questions one by one for us to solve ?????????

AIUI built-ins do not require fork exec and that is one of the reasons for having built-ins such as echo when perfectly good external commands like /bin/echo already exist. From the link (my emphasis) "A builtin is a command contained within the Bash tool set, literally built in. This is either for performance reasons -- builtins execute faster than external commands, which usually require forking off [1] a separate process"

If these are homework questions (and they could well be) they are unusual ones or strangely re-cast.

mohit_parihar 12-12-2009 02:47 AM

sir actually i m not posting all my assignment here. we were given an assignmment on working of shell. its our intrest to know extra in this field

ghostdog74 12-12-2009 03:39 AM

then its best to understand the source.

catkin 12-12-2009 04:05 AM

Quote:

Originally Posted by mohit_parihar (Post 3788604)
sir actually i m not posting all my assignment here. we were given an assignmment on working of shell. its our intrest to know extra in this field

Thanks for the confirmation :)

I thought as much. Your questions go beyond homework (they would be unfairly hard questions for homework when first learning bash). Nice that you are curious and want to fully understand :)

Several of your questions relate (indirectly) to *n*x processes. Your curiosity and hunger for deeper understanding would be rewarded by learning about processes. Here are some links. Best to start with the first because it explains processes as seen from the shell that you are already learning about.

Aquarius_Girl 12-13-2009 11:47 PM

Quote:

Originally Posted by catkin
AIUI built-ins do not require fork exec and that is one of the reasons for having built-ins such as echo when perfectly good external commands like /bin/echo already exist. From the link (my emphasis) "A builtin is a command contained within the Bash tool set, literally built in. This is either for performance reasons -- builtins execute faster than external commands, which usually require forking off [1] a separate process"

thanks for the enlightenment !

Of course, what will be the use of builtin commands if shell still had to fork a process for them ! They are there for the speed !

catkin 12-14-2009 03:43 AM

Quote:

Originally Posted by anishakaul (Post 3790462)
thanks for the enlightenment !

Of course, what will be the use of builtin commands if shell still had to fork a process for them ! They are there for the speed !

True -- and some of them because they would not work as external commands, the cd built-in for example. Can you figure out why an external cd command would not work (it's process-related)?

Aquarius_Girl 12-14-2009 03:49 AM

Quote:

Originally Posted by catkin
True -- and some of them because they would not work as external commands, the cd built-in for example. Can you figure out why an external cd command would not work (it's process-related)?

cd cannot work as an external command because an external command creates a child process, and a process cannot affect the environment of its parent (shell in this case). :)


All times are GMT -5. The time now is 05:17 PM.