|
1 | 1 | In this stage, you'll extend your shell's tab completion to include external executable files in the user's `PATH`. |
2 | 2 |
|
3 | | -Your shell should now be able to complete commands that are not built-ins, but exist as executable files in the directories listed in the `PATH` environment variable. |
4 | | -When the user types the beginning of an external command and presses `<TAB>`, your shell should complete the command to the full executable file name. |
5 | | -This means that if you have a command `custom_executable` in the path and type `custom` and press `<TAB>`, the shell should complete that to `custom_executable`. |
| 3 | +### Tab Completion for Executables |
| 4 | + |
| 5 | +In previous stages, you implemented tab completion for builtin commands (`echo` and `exit`). Now you'll extend completion to include external executables found in the PATH environment variable. |
| 6 | + |
| 7 | +When the user types the beginning of an executable's name and presses `<TAB>`, your shell should complete it to the full executable name. |
| 8 | + |
| 9 | +For example, if `custom_executable` exists in a directory listed in PATH, typing `custom` and pressing tab completes to `custom_executable ` (with a trailing space). |
6 | 10 |
|
7 | 11 | ### Tests |
8 | 12 |
|
9 | | -The tester will execute your program like this: |
| 13 | +The tester will create an executable file named `custom_executable` and add its directory to the `PATH`. |
| 14 | + |
| 15 | +It will then execute your program like this: |
10 | 16 |
|
11 | 17 | ```bash |
12 | 18 | ./your_program.sh |
13 | 19 | ``` |
14 | 20 |
|
15 | | -Before executing your shell, the tester will create an executable file named `custom_executable` and add its directory to the `PATH`. |
| 21 | +Next, the tester will simulate a user typing the start of the external command and pressing `<TAB>`: |
16 | 22 |
|
17 | | -The test will simulate the user typing the start of the external command and pressing `<TAB>`: |
18 | | - |
19 | | -1. **Input:** `custom`<TAB> |
20 | | - * The tester types "custom" and presses `<TAB>`. The tester expects that the prompt line changes to <code>custom_executable </code>. |
| 23 | +```bash |
| 24 | +$ custom<TAB> |
| 25 | +$ custom_executable |
| 26 | +``` |
21 | 27 |
|
22 | | -The tester will verify that your shell correctly completes the command to the external executable file name. Note the space at the end of the completion. |
| 28 | +The tester will verify that your shell correctly completes the command to the external executable file name. |
23 | 29 |
|
24 | 30 | ### Notes |
25 | 31 |
|
26 | | -- PATH can include directories that don't exist on disk, so your code should handle such cases gracefully. |
| 32 | +- PATH can include directories that don't exist on disk, so your code should handle such cases gracefully. |
0 commit comments