Skip to content

Commit 2f3d065

Browse files
authored
Merge pull request #184 from codecrafters-io/TropicolX-patch-23
Revise "Executable completion #gy5"
2 parents 802f7da + aa8c581 commit 2f3d065

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
In this stage, you'll extend your shell's tab completion to include external executable files in the user's `PATH`.
22

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).
610

711
### Tests
812

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:
1016

1117
```bash
1218
./your_program.sh
1319
```
1420

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>`:
1622

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+
```
2127

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.
2329

2430
### Notes
2531

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

Comments
 (0)