Skip to content

Commit 84da520

Browse files
authored
Merge pull request #185 from codecrafters-io/TropicolX-patch-24
Revise "Multiple completions #wh6"
2 parents 2f3d065 + f906baf commit 84da520

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed
Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
In this stage, you'll implement tab completion for executables, specifically when multiple executables share a common prefix.
1+
In this stage, you'll implement tab completion for multiple executables that share a common prefix.
22

3-
When the user types a command prefix and presses `<TAB>`, your shell should:
3+
### Handling Multiple Matches
44

5-
- Identify all executables in the `PATH` that match the prefix.
6-
- If there are multiple matches,
7-
- On the first TAB press, just ring a bell. (`\a` rings the bell)
8-
- On the second TAB press, print all the matching executables separated by 2 spaces, on the next line, and follow it with the prompt on a new line.
5+
When a user types a command prefix and presses `<TAB>`, your shell should find all executables in PATH that match the prefix and do the following:
6+
7+
1. On the first `<TAB>` press, ring the bell (using `\x07`).
8+
2. On the second `<TAB>` press:
9+
- Print all matching executables on a new line. List them in **alphabetical order**, separated by two spaces (<code style="white-space: pre;"> </code>).
10+
- Show the prompt again on the next line, keeping the original command prefix.
11+
12+
For example:
13+
14+
```bash
15+
$ xyz_<TAB><TAB>
16+
xyz_bar xyz_baz xyz_quz
17+
$ xyz_
18+
```
919

1020
### Tests
1121

@@ -15,17 +25,19 @@ The tester will execute your program like this:
1525
./your_program.sh
1626
```
1727

18-
It will then set up a specific `PATH` and place multiple executables starting with a common prefix into different directories in the `PATH`. Finally, it will type the common prefix, and then press the Tab key twice.
28+
It will then set up a specific `PATH` and place multiple executables starting with a common prefix into different directories in the `PATH`.
29+
30+
Finally, it will type the common prefix, and then press the tab key twice.
1931

2032
```bash
21-
$ ./your_program.sh
2233
$ xyz_<TAB><TAB>
2334
xyz_bar xyz_baz xyz_quz
2435
$ xyz_
2536
```
2637

2738
The tester will verify that:
28-
29-
1. Your shell displays the prompt with the common prefix after receiving the partial command.
30-
2. Upon the first Tab key press, your shell prints a bell character.
31-
3. Upon the second Tab key press, your shell prints the list of matching executables separated by 2 spaces, on the next line, and follow it with the prompt on a new line.
39+
1. The first tab press rings the bell.
40+
2. The second tab press displays all matching executables in alphabetical order.
41+
- The matches are separated by two spaces.
42+
- The matches are displayed on a new line.
43+
3. The prompt reappears with the original input preserved.

0 commit comments

Comments
 (0)