Skip to content

Commit daa6997

Browse files
committed
Update command handling instructions in course-definition.yml
Enhance the command execution logic by specifying behavior for commands with and without execute permissions. The updated instructions clarify that commands without execute permissions will be skipped, while those with permissions will print their path. This aims to improve user understanding of command execution outcomes.
1 parent 8692abc commit daa6997

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

course-definition.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,13 @@ stages:
314314
315315
[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.
316316
317-
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`.
317+
For example, PATH like `/dir1:/dir2:/dir3` means that the program should search for the command in `/dir1`, then `/dir2`, and finally `/dir3`, in that order.
318+
319+
Caveat: Not all commands found are necessarily executable.
320+
321+
- If the command is found (but it does not have execute permissions), the program should skip it and continue searching.
322+
- If the command is found (and it has execute permissions), the program should print the path to the command.
323+
- If the command is not found, the program should print `<command>: not found`.
318324
319325
### Tests
320326
@@ -329,8 +335,14 @@ stages:
329335
```bash
330336
$ type ls
331337
ls is /usr/bin/ls
338+
```
339+
340+
```bash
332341
$ type valid_command
333342
valid_command is /usr/local/bin/valid_command
343+
```
344+
345+
```bash
334346
$ type invalid_command
335347
invalid_command: not found
336348
$
@@ -341,8 +353,9 @@ stages:
341353
### Notes
342354
343355
- The actual value of the `PATH` environment variable will be random for each test case.
344-
- `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.
345356
- 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.
357+
- PATH can include directories that don’t exist on disk, so your code should handle such cases gracefully.
358+
346359
marketing_md: |-
347360
In this stage, you'll implement the `type` builtin command for your shell.
348361
@@ -1120,8 +1133,11 @@ stages:
11201133
1. **Input:** `custom`<TAB>
11211134
* The tester types "custom" and presses `<TAB>`. The tester expects that the prompt line changes to <code>custom_executable </code>.
11221135
1123-
The tester will verify that your shell correctly completes the command to the external executable file name.
1124-
Note the space at the end of the completion.
1136+
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.
1137+
1138+
### Notes
1139+
1140+
- PATH can include directories that don't exist on disk, so your code should handle such cases gracefully.
11251141
11261142
marketing_md: |-
11271143
In this stage, you'll implement support for autocompleting external executables.

0 commit comments

Comments
 (0)