Link Search Menu Expand Document

Path resolution

You probably found that it was a pain to test your shell in the previous part because you had to type the full path of every program. Luckily, every program (including your shell program) has access to a set of environment variables, which is structured as a hashtable of string keys to string values. One of these environment variables is the PATH variable. You can print the PATH variable of your development environment.

echo $PATH

When bash or any other shell executes a program like wc, it looks for a program called wc in each directory listed in the PATH environment variable and runs the first one that it finds. The directories in PATH are separated with a colon.

Modify your shell so that it uses the PATH variable from the environment to resolve program names. Typing in the full pathname of the executable should still be supported. Do not use execvp since the autograder looks for execvp, and you won’t receive a grade if that word is found. Use execv instead and implement your own PATH resolution.