You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: course-definition.yml
+20-4Lines changed: 20 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -314,7 +314,13 @@ stages:
314
314
315
315
[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.
316
316
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`.
318
324
319
325
### Tests
320
326
@@ -329,8 +335,14 @@ stages:
329
335
```bash
330
336
$ type ls
331
337
ls is /usr/bin/ls
338
+
```
339
+
340
+
```bash
332
341
$ type valid_command
333
342
valid_command is /usr/local/bin/valid_command
343
+
```
344
+
345
+
```bash
334
346
$ type invalid_command
335
347
invalid_command: not found
336
348
$
@@ -341,8 +353,9 @@ stages:
341
353
### Notes
342
354
343
355
- 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.
345
356
- 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
+
346
359
marketing_md: |-
347
360
In this stage, you'll implement the `type` builtin command for your shell.
348
361
@@ -1120,8 +1133,11 @@ stages:
1120
1133
1. **Input:** `custom`<TAB>
1121
1134
* The tester types "custom" and presses `<TAB>`. The tester expects that the prompt line changes to <code>custom_executable </code>.
1122
1135
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.
1125
1141
1126
1142
marketing_md: |-
1127
1143
In this stage, you'll implement support for autocompleting external executables.
0 commit comments