Skip to content

Commit 0739f95

Browse files
committed
Refactor course-definition.yml: Add navigation extensions and implement pwd and cd builtins
1 parent 291d773 commit 0739f95

File tree

1 file changed

+137
-118
lines changed

1 file changed

+137
-118
lines changed

course-definition.yml

Lines changed: 137 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ marketing:
3838
I think the instant feedback right there in the git push is really cool.
3939
Didn't even know that was possible!
4040
41-
# extensions:
42-
# - slug: "navigation"
43-
# name: "Directory Navigation"
44-
# description_markdown: |
45-
# In this challenge extension, you'll add directory navigation support to your shell implementation by introducing the `cd` and `pwd` commands.
41+
extensions:
42+
- slug: "navigation"
43+
name: "Navigation"
44+
description_markdown: |
45+
In this challenge extension, you'll add directory navigation support by implementing the `cd` and `pwd` commands.
4646
47-
# Along the way, you'll learn about handling paths, changing the current working directory, and printing the current working directory. These commands are essential for effective navigation and file system management in any shell environment.
47+
Along the way, you'll learn about what the "current working directory" is, how to change it and more.
4848
4949
stages:
5050
- slug: "oo8"
@@ -327,154 +327,173 @@ stages:
327327
marketing_md: |-
328328
In this stage, you'll implement the ability for your shell to run external programs with arguments.
329329
330-
# - slug: "ei0"
331-
# primary_extension_slug: "navigation"
332-
# name: "The pwd builtin"
333-
# difficulty: easy
334-
# description_md: |-
335-
# In this stage, you'll implement the `pwd` builtin command for your shell.
330+
- slug: "ei0"
331+
primary_extension_slug: "navigation"
332+
name: "The pwd builtin"
333+
difficulty: easy
334+
description_md: |-
335+
In this stage, you'll implement the `pwd` builtin command.
336336
337-
# [pwd](https://en.wikipedia.org/wiki/Pwd) stands for "print working directory" and is used to output the current working directory. This command is essential for users to know their current location in the filesystem.
337+
[pwd](https://en.wikipedia.org/wiki/Pwd) stands for "print working directory".
338338
339-
# ### Tests
339+
### Tests
340340
341-
# The tester will execute your program like this:
341+
The tester will execute your program like this:
342342
343-
# ```bash
344-
# ./your_shell.sh
345-
# ```
343+
```bash
344+
./your_shell.sh
345+
```
346346
347-
# It'll then send a `pwd` command to your shell:
347+
It'll then send a `pwd` command to your shell:
348348
349-
# ```bash
350-
# $ pwd
351-
# /path/to/current/directory
352-
# $
353-
# ```
349+
```bash
350+
$ pwd
351+
/path/to/current/directory
352+
$
353+
```
354354
355-
# The tester will check if the `pwd` command correctly prints the current working directory.
355+
The tester will check if the `pwd` command correctly prints the current working directory.
356356
357-
# ### Notes
357+
### Notes
358358
359-
# - Ensure that the `pwd` command outputs the full path of the current working directory.
360-
# marketing_md: |-
361-
# In this stage, you'll implement the ability for your shell to print the current working directory.
359+
- The `pwd` command must print the full absolute path of the current working directory.
360+
marketing_md: |-
361+
In this stage, you'll implement the ability for your shell to print the current working directory.
362362
363-
# - slug: "ra6"
364-
# primary_extension_slug: "navigation"
365-
# name: "The cd builtin: Absolute paths"
366-
# difficulty: medium
367-
# description_md: |-
368-
# In this stage, you'll implement the `cd` builtin command to handle absolute paths for your shell.
363+
- slug: "ra6"
364+
primary_extension_slug: "navigation"
365+
name: "The cd builtin: Absolute paths"
366+
difficulty: medium
367+
description_md: |-
368+
In this stage, you'll implement the `cd` builtin command to handle absolute paths.
369369
370-
# The `cd` command is used to change the current working directory. When an absolute path to an existing directory is provided, the shell should change the current working directory to that path. If the directory doesn't exist, it should print an error message indicating that the directory was not found.
370+
The `cd` command is used to change the current working directory. `cd` can receive multiple
371+
argument types. In this challenge we'll cover:
371372
372-
# ### Tests
373+
- Absolute paths, like `/usr/local/bin`. (**This stage**)
374+
- Relative paths, like `./`, `../`, `./dir`. (Later stages)
375+
- The `~` character, which stands for the user's home directory (Later stages)
373376
374-
# The tester will execute your program like this:
377+
### Tests
375378
376-
# ```bash
377-
# ./your_shell.sh
378-
# ```
379+
The tester will execute your program like this:
379380
380-
# It'll then send a series of `cd` commands to your shell:
381+
```bash
382+
./your_shell.sh
383+
```
381384
382-
# ```bash
383-
# $ cd /usr/local/bin
384-
# $ pwd
385-
# /usr/local/bin
386-
# $ cd /does_not_exist
387-
# cd: /does_not_exist: No such file or directory
388-
# $
389-
# ```
385+
It'll then send a series of `cd` commands to your shell:
390386
391-
# The tester will check if the `cd` command correctly changes the directory when a valid path is provided and if it properly handles invalid paths by displaying an appropriate error message.
387+
```bash
388+
$ cd /usr/local/bin
389+
$ pwd
390+
/usr/local/bin
391+
$ cd /does_not_exist
392+
cd: /does_not_exist: No such file or directory
393+
$
394+
```
392395
393-
# ### Notes
396+
The tester will check if the `cd` command correctly changes the directory when a valid path is provided. It'll
397+
also check whether the message `cd: <directory>: No such file or directory` is printed if the provided path is invalid.
394398
395-
# - If the specified directory does not exist, print `cd: <directory>: No such file or directory`.
396-
# - The `pwd` command will be used to verify the current working directory after using `cd`.
397-
# ```
398-
# marketing_md: |-
399-
# In this stage, you'll implement the ability for your shell to run the `cd` builtin command with absolute paths.
399+
### Notes
400400
401-
# - slug: "gq9"
402-
# primary_extension_slug: "navigation"
403-
# name: "The cd builtin: Relative paths"
404-
# difficulty: hard
405-
# description_md: |-
406-
# In this stage, you'll implement the `cd` builtin command to handle relative paths for your shell.
401+
- The `cd` command doesn't print anything if the directory is changed successfully. The tester will use `pwd` to verify
402+
the current working directory after using `cd`.
403+
marketing_md: |-
404+
In this stage, you'll implement the ability for your shell to run the `cd` builtin command with absolute paths.
407405
408-
# The `cd` command should be able to change the current working directory using relative paths. Relative paths are specified relative to the current directory. If the specified directory does not exist, it should print an error message indicating that the directory was not found.
406+
- slug: "gq9"
407+
primary_extension_slug: "navigation"
408+
name: "The cd builtin: Relative paths"
409+
difficulty: hard
410+
description_md: |-
411+
In this stage, you'll extend your `cd` builtin command to handle relative paths.
409412
410-
# ### Tests
413+
As a recap, `cd` can receive multiple argument types:
411414
412-
# The tester will execute your program like this:
415+
- Absolute paths, like `/usr/local/bin`. (Previous stages)
416+
- Relative paths, like `./`, `../`, `./dir`. (**This stage**)
417+
- The `~` character, which stands for the user's home directory (Later stages)
413418
414-
# ```bash
415-
# ./your_shell.sh
416-
# ```
419+
### Tests
417420
418-
# It'll then send a series of `cd` commands to your shell:
421+
The tester will execute your program like this:
419422
420-
# ```bash
421-
# $ cd /usr
422-
# $ pwd
423-
# /usr
424-
# $ cd ./local/bin
425-
# $ pwd
426-
# /usr/local/bin
427-
# $ cd ../../
428-
# $ pwd
429-
# /usr
430-
# $
431-
# ```
423+
```bash
424+
./your_shell.sh
425+
```
432426
433-
# The tester will check if the `cd` command correctly changes the directory using relative paths and if it properly handles invalid paths by displaying an appropriate error message.
427+
It'll then send a series of `cd` commands to your shell:
434428
435-
# ### Notes
429+
```bash
430+
$ cd /usr
431+
$ pwd
432+
/usr
433+
$ cd ./local/bin
434+
$ pwd
435+
/usr/local/bin
436+
$ cd ../../
437+
$ pwd
438+
/usr
439+
$
440+
```
436441
437-
# - The `pwd` command will be used to verify the current working directory after using `cd`.
438-
# - If the specified directory does not exist, print `cd: <directory>: No such file or directory`.
439-
# - Relative paths like `./`, `../`, and more complex relative paths should be handled correctly.
440-
# marketing_md: |-
441-
# In this stage, you'll implement the ability for your shell to run the `cd` builtin command with relative paths.
442+
The tester will check if the `cd` command correctly changes the directory when a valid path is provided. It'll
443+
also check whether the message `cd: <directory>: No such file or directory` is printed if the provided path is invalid.
442444
443-
# - slug: "gp4"
444-
# primary_extension_slug: "navigation"
445-
# name: "The cd builtin: Home directory"
446-
# difficulty: medium
447-
# description_md: |-
448-
# In this stage, you'll implement the `cd` builtin command to handle the `~` character for your shell.
445+
### Notes
449446
450-
# The `~` character is a shorthand for the user's home directory. When `cd` is received with `~`, your shell should change the current working directory to the user's home directory. This feature enhances user convenience, making it easier to navigate to the home directory.
447+
- The actual directory names used will be random, so you can't hardcode the expected output.
448+
- Relative paths like `./`, `../`, and more complex relative paths should be handled correctly.
449+
- The `cd` command doesn't print anything if the directory is changed successfully. The tester will use `pwd` to verify
450+
the current working directory after using `cd`.
451+
marketing_md: |-
452+
In this stage, you'll implement the ability for your shell to run the `cd` builtin command with relative paths.
451453
452-
# ### Tests
454+
- slug: "gp4"
455+
primary_extension_slug: "navigation"
456+
name: "The cd builtin: Home directory"
457+
difficulty: medium
458+
description_md: |-
459+
In this stage, you'll extend your `cd` builtin command to handle the `~` character.
453460
454-
# The tester will execute your program like this:
461+
As a recap, `cd` can receive multiple argument types:
455462
456-
# ```bash
457-
# ./your_shell.sh
458-
# ```
463+
- Absolute paths, like `/usr/local/bin`. (Previous stages)
464+
- Relative paths, like `./`, `../`, `./dir`. (Previous stages)
465+
- The `~` character, which stands for the user's home directory (**This stage**)
459466
460-
# It'll then send a series of `cd` commands to your shell:
467+
The `~` character is shorthand for the user's home directory. When `cd` is received with `~`, your shell should
468+
change the current working directory to the user's home directory. The home directory is specified by the
469+
[`HOME`](https://unix.stackexchange.com/questions/123858/is-the-home-environment-variable-always-set-on-a-linux-system)
470+
environment variable.
461471
462-
# ```bash
463-
# $ cd /usr/local/bin
464-
# $ pwd
465-
# /usr/local/bin
466-
# $ cd ~
467-
# $ pwd
468-
# /home/user
469-
# $
470-
# ```
472+
### Tests
471473
472-
# The tester will check if the `cd` command correctly changes the directory to the user's home directory when `~` is used. You need to fetch the user's home directory from the `HOME` environment variable.
474+
The tester will execute your program like this:
473475
474-
# ### Notes
476+
```bash
477+
./your_shell.sh
478+
```
479+
480+
It'll then send a series of `cd` commands to your shell:
481+
482+
```bash
483+
$ cd /usr/local/bin
484+
$ pwd
485+
/usr/local/bin
486+
$ cd ~
487+
$ pwd
488+
/home/user
489+
$
490+
```
491+
492+
The tester will check if the `cd` command correctly changes the directory to the user's home directory when `~` is used.
475493
476-
# - Ensure that the `cd` command interprets `~` as the user's home directory.
477-
# - The `pwd` command will be used to verify the current working directory after using `cd ~`.
478-
# - The home directory is typically specified by the `HOME` environment variable.
479-
# marketing_md: |-
480-
# In this stage, you'll implement the ability for your shell to run the `cd` builtin command with the `HOME` directory.
494+
### Notes
495+
496+
- The `pwd` command will be used to verify the current working directory after using `cd ~`.
497+
- The home directory is specified by the `HOME` environment variable.
498+
marketing_md: |-
499+
In this stage, you'll implement the ability for your shell to run the `cd` builtin command with the `HOME` directory.

0 commit comments

Comments
 (0)