How does bash process user input from the command line
Running Ubuntu 19.10 have a question about Bash
How does bash process user input such as a command like "ls -a" ? How is this actually done in detail as possible ? |
From here:
Quote:
And here are all the gory details. In particular: Quote:
|
Quote:
https://github.com/coreutils/coreuti...aster/src/ls.c http://www.gnu.org/software/coreutils/ http://git.savannah.gnu.org/cgit/cor.../tree/src/ls.c |
In short:
it forks a subshell that execs into an "ls -a". |
Quote:
|
No, they are for the source code of ls.
|
Quote:
If you are on Ubuntu or other dpkg-based distro, you can fetch the source package with apt-src or apt-get like this: Code:
cd /tmp/ |
Quote:
|
Thank you shruggy. I have a question to ask. How did you figure out what system calls are being executed ? Did you use ltrace and strace or even gdb ?
|
yes, strace will tell you.
But in general those are the fork and exec (to start another process). |
Quote:
|
Actually on a recent Linux system strace will report clone() rather than fork().
|
Quote:
Please advise. Thanks. |
what to advice? there was no fork that's why you can't find it.
ls is a simple binary, it does not fork any other process. about exec: see the man page: https://man7.org/linux/man-pages/man3/exec.3.html (and the description) |
Quote:
Thanks |
All times are GMT -5. The time now is 08:52 AM. |