Let’s look at a specific case but let’s clarify concepts of what a terminal is and what a shell is since they are not the same thing.
Input and output environment in text
Command line interpreter.
ready then we know that the term refers to the environment where we are going to work and the shell is the one that understands the commands we type.
we will now focus on the ls command,
the command ls lists the files and the argument -l lists the files in long format, looks like this:
let’s do a step count that the shell has to do in order to execute that command
- The shell is always waiting for a command, this is done with an infinite loop, and asks for text input with the getline function when the ls -l command is entered it is stored in the getline buffer.
- there are two ways to pass the command with the full path or without the path, in this case, we will see ls,
the shell this ls takes it as a string she creates a child process, here she passes all the magic, the ls command or any other these are files that are in the environment the shell has to look for that command in the environment it is usually in the path
that looks something like this:
- The shell has to divide each directory in the path by “:”, an example of this can be seen best:
- When he has each directory in the path he will make a concatenation of the command path plus the command and he will check directory by directory where the file is.
- He finds the command he saves that path along with the command, at this point the shell already knows where the command is, what he is going to do now is execute it, the output we already know gives this, but maybe we didn’t know what the shell had to do to interpret the command.
Well, when he executes the command, he expects a command again,
the “-l” is already interpreted when the ls command is executed, the shell passes the whole string to the ls and the -l to be executed.
At this point the shell could have interpreted the command if it had not been so, it would not have found it in the path.
Remember try to look for the background of things, always what is behind something.
thanks for reading, this blog was made by :
Julian Alvarez Caro
I hope you liked it.