Skip to content

Tweak instructions for #mg5 Type: executable and #gy5 Executable completion #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions course-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,13 @@ stages:
description_md: |-
In this stage, you'll extend the `type` builtin to search for executable files using [PATH](https://en.wikipedia.org/wiki/PATH_(variable)).

[PATH](https://en.wikipedia.org/wiki/PATH_(variable)) is an environment variable that specifies a set of directories where executable programs are located. When a command is received, the program should search for the command in the directories listed in the PATH environment variable.
[PATH](https://en.wikipedia.org/wiki/PATH_(variable)) is an environment variable that specifies a set of directories where executable programs are located. When a command is received, your shell should search for the command in the directories listed in the PATH environment variable.

If the command is found, the program should print the path to the command. If the command is not found, the program should print `<command>: not found`.
For example, if PATH is `/dir1:/dir2:/dir3`, your shell should search in `/dir1`, then `/dir2`, and finally `/dir3`, in that order.

- If a matching file is found but it does not have execute permissions, your shell should skip it and continue searching.
- If a matching files is found and it has execute permissions, your shell should print the path to the file.
- If no matching files are found, your shell should print `<command>: not found`.

### Tests

Expand All @@ -341,8 +345,9 @@ stages:
### Notes

- The actual value of the `PATH` environment variable will be random for each test case.
- `PATH` can contain multiple directories separated by colons (`:`), your program should search for programs in each directory in order and return the first match which has executable permissions.
- Some commands, such as `echo`, can exist as both builtin commands and executable files. In such cases, the `type` command should identify them as builtins.
- PATH can include directories that don’t exist on disk, so your code should handle such cases gracefully.

marketing_md: |-
In this stage, you'll implement the `type` builtin command for your shell.

Expand Down Expand Up @@ -1120,8 +1125,11 @@ stages:
1. **Input:** `custom`<TAB>
* The tester types "custom" and presses `<TAB>`. The tester expects that the prompt line changes to <code>custom_executable </code>.

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

### Notes

- PATH can include directories that don't exist on disk, so your code should handle such cases gracefully.

marketing_md: |-
In this stage, you'll implement support for autocompleting external executables.
Expand Down
Loading