LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How can I edit a command? (https://www.linuxquestions.org/questions/linux-newbie-8/how-can-i-edit-a-command-913328/)

tronayne 11-14-2011 08:59 AM

Quote:

Originally Posted by Stephen Morgan (Post 4523502)
I believe cd is a shell built-in command, rather than a programme with its own source code.

Well, duh! Yup, cd is definitely part of the shell -- of course, one could modify the source to change the behavior of cd but that may be equivalent to those little dancing dogs you see in the circus: the question is not how well but rather why at all, methinks.

venom4u31 11-14-2011 02:31 PM

Quote:

Originally Posted by MTK358 (Post 4523583)
I don't know why anyone marked this as unhelpful, because it's true.

In fact, it's impossible to create a separate program that changes the current directory of the shell, since each process (including the shell and command) has its own separate current directory.

Relax, it's not that unhelpful. I was only asking about reverse engineering the code from the executable (in the case of compiled programs), which I believe that most of the installed programs are.

frieza 11-14-2011 02:51 PM

there are two different types of commands
'internal' and 'external' commands
internal commands are part of the shell
external commands are separate binaries that are executed by the shell
a lot of the basic commands that are not internal commands (such as ls) can be found in the 'coreutils' package

chrism01 11-15-2011 07:15 PM

The thing to be clear on, is that whether the cmd is part of the shell, or 'external', Linux is FOSS (Free & Open Src SW).
This means that the src code should be available from your normal repos. Most distros don't install the src code by default, because most people don't want/need it.

Note that some distros also give access to non-open SW.
That would involve reverse engineering, which is likely illegal ... depending on jurisdiction/reason for doing so etc.

What Sw do you want to see the src for?

opensourcewj 11-15-2011 07:48 PM

"man alias" you will get what you want.

Roken 11-15-2011 08:17 PM

On the off chance that anyone does want to modify a shell built in function, you can get the source for the shell and modify to your hearts content. As has been said many times in this thread, FOSS (Free open source software) is exactly what it says on the tin, open source. If the source hasn't been made readily available, and if you know it's covered by the gnu license, ask the package author for the source (he'll supply it under the terms of the license).

As has also been said, you hit a problem with closed source propriety stuff (which most of GNU/linux isn't) but beyond that the world is your oyster.


All times are GMT -5. The time now is 07:47 AM.