I am confused with regards to the following - if I execute a script or run a program in the current shell by typing on its name
- it searches in the $PATH variable, to find the location of the executable
- once it finds it, does it run the executable in the current shell or will spawn a child shell/process to run the executable ?
I believe a new child process will be spawned to run the executable, but having said that, how does the child process know (the path to the executable) to run the executable ? — if I amended the PATH in the parent shell so that it can find the executable (using only PATH=$PATH:/newpath/to/executable) but not doing an export
e.g., — I did not do an export here $ PATH=$PATH:/path/to/executable $ executable
When the parent shell finds the executable, what does it do next (spawn a child process? run the executable?). But again, how does the child process find the executable when the edited PATH environment is not exported to it