How can I edit a command?
Some commands (or most), as far as I know are stored inside files within the bin folder. My question is how can I edit such commands? For example, if I want to change what cd does, how can I do that?
Obviously, I don't want to change those basic commands, but I want to change custom commands that might be installed by me. |
Get the source, edit the source, compile the source and install it (preferably with a different name -- when you get updates for your system, they'll overwrite existing files).
The source may already be on your distribution media (Slackware is) or you'll need to find it at your distribution web site. Hope this helps some. |
I wouldn't recommend changing the original commands. You could create your own commands. This can be done in 2 ways:
a) Create an alias in ~/.bashrc eg. Code:
alias elisp='cd /home/sycamorex/data/projects/programming/lisp ; emacs -nw' b) create a directory ~/bin and add it to your path by adding "export PATH=$PATH:~/bin" to ~/.bashrc After that create shell scripts in ~/bin For example, a program that lists all my aliases: Code:
#!/bin/bash chmod +x ~/bin/name_of_the_file |
Quote:
|
Quote:
|
Hi there,
Quote:
Quote:
For simple tasks, script languages like Perl or PHP may be sufficient; these programs aren't compiled (i.e. translated into machine code), but instead remain human-readable, and the so-called interpreter translates them on-the-fly each time they're executed. What's really suitable for you depends very much on what you want to achieve, and what programming skills and experience you already have. [X] Doc CPU |
Quote:
|
Quote:
Depending on a distribution, the sources might already be installed on the system. If not, it's easy to install them. |
Quote:
|
Hi there,
Quote:
Besides, yes, it is possible to reverse-engineer the machine code and reconstruct the source to a certain extent. But you have no identifiers (symbols, variable or function names) because they're left behind during compilation. You have no comments that tell you how a few lines of code are supposed to work. So that hard work isn't worth the effort, unless you're talking about closed-source software and you have a very strong motivation to disclose how it works. [X] Doc CPU |
Which distro are you using and what programs are we talking about?
If these are not open-source programs then you've got a problem:) |
Quote:
If you're trying to reverse-engineer a proprietary package, well, that's different (and you're on your own for that one -- don't be naughty). The key phrase is "free and open source;" that literally means you can get the source for anything that is free and open source, just go look for it (Google is your fiend here). You've obviously got internet access: Want the source code for VirtualBox -- go download it; what the source for LibreOffice -- go download it; want the source for cd -- go download it. Hope this helps some. |
Quote:
|
I believe cd is a shell built-in command, rather than a programme with its own source code.
|
Quote:
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. |
Quote:
|
Quote:
|
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 |
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? |
"man alias" you will get what you want.
|
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 05:32 PM. |