LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   source code for fg, bg command (https://www.linuxquestions.org/questions/linux-general-1/source-code-for-fg-bg-command-774427/)

mohit_parihar 12-09-2009 02:44 AM

source code for fg, bg command
 
can any one tell me where can i found the source code for fg and bg command. I have tried and searched every where but i am unable to find it. even on running which <fg command> and also for bg comand. I am not able to find even the patch file.

EricTRA 12-09-2009 02:53 AM

Hello,

I provided you with an answer to the same question on a thread where you posted it too. http://www.linuxquestions.org/questi...54#post3783754

Have you had a look at those links I provided?

Kind regards,

Eric

mohit_parihar 12-10-2009 03:04 AM

I could not find anything there, please help me with the question.

colucix 12-10-2009 03:55 AM

The linuxfromscratch link provided by EricTRA was indeed a good starting point. I suggest an alternative and a method you can follow for other similar searches in the future. First use the type command to see which is the actual command executed (take in mind that some commands like echo, can be either a shell built-in or a standalone program. The type command will tell you which of them is currently used by your system).
Code:

$ type fg
fg is a shell builtin

as you can see the fg command is a shell built-in. And it is only and uniquely a shell built-in. This means the source code of fg is built into the code of the shell itself. If using BASH, your best bet to find the code you're looking for is to download the source code for bash (eventually verify which version of bash you've installed and download that exact version).

Take in mind that bash - as any other GNU software - is available for download at the GNU website, www.gnu.org.

If your intent is to apply a patch, first it is strongly advised that you apply only the official ones. And it is even more strongly suggested that you wait for the updated package released by your linux distribution. Said that, since you're running on a RPM based system, if you really want to apply a patch you can download the source RPM and rebuild it.

Back to the search of source code in general, suppose the type command returns the path to an executable (here we are talking about an external program - external as opposite of shell built-in). In this case you can try the rpm command to find out which package provided the executable, then you can look for and download the source code on the official (developer or project) site. Here is an example, taken from my CentOS box:
Code:

$ type thunderbird
thunderbird is /usr/bin/thunderbird
$ rpm -qf /usr/bin/thunderbird
thunderbird-2.0.0.22-2.el5.centos
$ rpm -qi thunderbird
Name        : thunderbird                  Relocations: (not relocatable)
Version    : 2.0.0.22                          Vendor: CentOS
Release    : 2.el5.centos                  Build Date: Fri 26 Jun 2009 12:08:45 AM CEST
Install Date: Thu 16 Jul 2009 12:52:15 PM CEST      Build Host: builder16.centos.org
Group      : Applications/Internet        Source RPM: thunderbird-2.0.0.22-2.el5.centos.src.rpm
Size        : 47338016                        License: MPL
Signature  : DSA/SHA1, Fri 26 Jun 2009 04:07:53 PM CEST, Key ID a8a447dce8562897
URL        : http://www.mozilla.org/projects/thunderbird/
Summary    : Mozilla Thunderbird mail/newsgroup client
Description :
Mozilla Thunderbird is a standalone mail and newsgroup client.

Next step is to browse the official site and look for the source code.

Take in mind that in many cases you will be able to find the source code as source RPMs. This is especially true for software/packages built and provided by the official linux distribution you're running on. Just adding the Source RPM repository to the list of available software sources, should let you have easy and quick access to the code.

Hope this helps!

i92guboj 12-10-2009 04:00 AM

Quote:

Originally Posted by mohit_parihar (Post 3786367)
I could not find anything there, please help me with the question.

The response is on the other thread, if you didn't understand it completely, or at all, the right thing to do is to ask for further clarification on that same thread.

There's no need to open a new one. On the contrary, that is usually annoying to some users. Duplication of threads is also against the common netiquette.


As the other person said in your other thread, fg and bg are part of the shell (more correctly, they are shell builtins), so it's the source code for your shell what you should be looking for. In most distros nowadays, the default is bash.


All times are GMT -5. The time now is 02:20 AM.