generated from codecrafters-io/course-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
course-definition.yml
928 lines (687 loc) · 30.6 KB
/
course-definition.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
slug: "shell"
name: "Build your own Shell"
short_name: "Shell"
release_status: "live"
description_md: |-
A shell is a command-line interface that executes commands and manages processes. In this challenge, you'll build your own
[POSIX compliant](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html) shell that's capable of interpreting
shell commands, running external programs and builtin commands like `cd`, `pwd`, `echo` and more.
Along the way, you'll learn about shell command parsing, REPLs, builtin commands, and more.
short_description_md: |-
Learn about parsing shell commands, executing programs and more
completion_percentage: 20
languages:
- slug: "c"
- slug: "cpp"
- slug: "csharp"
- slug: "go"
- slug: "java"
- slug: "javascript"
- slug: "kotlin"
- slug: "php"
- slug: "python"
- slug: "ruby"
- slug: "rust"
- slug: "typescript"
- slug: "zig"
marketing:
difficulty: medium
sample_extension_idea_title: "Command History"
sample_extension_idea_description: "View and recall previously entered commands in your shell."
testimonials:
- author_name: "Ananthalakshmi Sankar"
author_description: "Automation Engineer at Apple"
author_avatar: "https://codecrafters.io/images/external/testimonials/oxta.jpeg"
link: "https://github.com/anu294"
text: "There are few sites I like as much that have a step by step guide. The real-time feedback is so good, it's creepy!"
- author_name: "Patrick Burris"
author_description: "Senior Software Developer, CenturyLink"
author_avatar: "https://codecrafters.io/images/external/testimonials/patrick-burris.jpeg"
link: "https://github.com/Jumballaya"
text: |-
I think the instant feedback right there in the git push is really cool.
Didn't even know that was possible!
extensions:
- slug: "navigation"
name: "Navigation"
description_markdown: |
In this challenge extension, you'll add directory navigation support by implementing the `cd` and `pwd` commands.
Along the way, you'll learn about what the "current working directory" is, how to change it and more.
- slug: "quoting"
name: "Quoting"
description_markdown: |
In this challenge extension, you'll add quoting support to your shell.
Quoting allows you to preserve whitespace and special characters in your shell commands.
- slug: "redirection"
name: "Redirection"
description_markdown: |
In this challenge extension, you'll add redirection support to your shell.
Redirection allows you to redirect the output of a command to a file or another command.
stages:
- slug: "oo8"
name: "Print a prompt"
difficulty: very_easy
description_md: |-
In this stage, you'll implement printing a shell prompt (`$ `) and waiting for user input.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
The tester will then check whether your shell prints the `$ ` prompt and waits for user input.
### Notes
- There's a space after the `$` character in the prompt.
- Your program must not exit after printing `$ `, it should wait for user input.
- We'll handle reading commands and executing them in later stages, this stage only deals with printing the prompt.
marketing_md: |-
In this stage, you'll implement printing the shell prompt and waiting for user input.
- slug: "cz2"
name: "Handle invalid commands"
difficulty: easy
description_md: |-
In this stage, you'll implement support for handling invalid commands in your shell.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It will then send the following command to your shell:
```bash
$ invalid_command
invalid_command: command not found
```
The tester will check whether your shell prints `<command_name>: command not found\n` for an invalid command.
### Notes
- We're treating every command as "invalid" for now, but we'll handle executing "valid" commands like `echo`, `cd` etc. in later stages.
- The command name will be a random string, so the response can't be hardcoded.
- In this stage it's okay if your program exits soon after printing the `<command_name>: command not found\n` message. In later stages
we'll check for a REPL (Read-Eval-Print Loop), i.e. whether the shell prints a new prompt after processing each command.
marketing_md: |-
In this stage, you'll implement handling invalid commands in your shell.
- slug: "ff0"
name: "REPL"
difficulty: medium
description_md: |-
In this stage, you'll implement a [REPL (Read-Eval-Print Loop)](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop).
A REPL is an interactive loop that reads user input, evaluates it, prints the result, and then waits for the next input.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It will then send a series of commands to your shell:
```bash
$ invalid_command_1
invalid_command_1: command not found
$ invalid_command_2
invalid_command_2: command not found
$ invalid_command_3
invalid_command_3: command not found
$
```
After each command, the tester will check if `<command_name>: command not found` is printed, and whether a prompt is printed for the next command.
### Notes
- The exact number of commands sent and the command names will be random.
- Just like the previous stages, all commands will be invalid commands, so the response will always be `<command_name>: command not found`.
marketing_md: |-
In this stage, you'll implement a REPL (Read-Eval-Print Loop) for your shell.
- slug: "pn5"
name: "The exit builtin"
difficulty: easy
description_md: |-
In this stage, you'll implement the [exit](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#exit) builtin.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send an invalid command to your shell, followed by the `exit` command:
```bash
$ invalid_command_1
invalid_command_1: command not found
$ exit 0
```
After issuing the `exit 0` command, the tester will verify whether your program terminates with [code/status](https://en.wikipedia.org/wiki/Exit_status) 0.
### Notes
- The tester will always pass in `0` as the argument to the `exit` command.
marketing_md: |-
In this stage, you'll implement the `exit` builtin command.
- slug: "iz3"
name: "The echo builtin"
difficulty: medium
description_md: |-
In this stage, you'll implement the [echo](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html) builtin.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `echo` commands to your shell:
```bash
$ echo hello world
hello world
$ echo pineapple strawberry
pineapple strawberry
$
```
After each command, the tester will check if the `echo` command correctly prints the provided text back.
marketing_md: |-
In this stage, you'll implement the `echo` builtin command.
- slug: "ez5"
name: "The type builtin: builtins"
difficulty: medium
description_md: |-
In this stage, you'll implement the `type` builtin command for your shell.
The `type` builtin is used to determine how a command would be interpreted if used. Example:
```bash
$ type echo
echo is a shell builtin
$ type exit
exit is a shell builtin
$ type invalid_command
invalid_command: not found
```
In this stage we'll only test two cases: builtin commands and unrecognized commands. We'll handle
executable files in later stages.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `type` commands to your shell:
```bash
$ type echo
echo is a shell builtin
$ type exit
exit is a shell builtin
$ type type
type is a shell builtin
$ type invalid_command
invalid_command: not found
$
```
The tester will check if the `type` command responds correctly based on the command provided:
- If a command is a shell builtin, the expected output is `<command> is a shell builtin`.
- If a command is not recognized, the expected output is `<command>: not found`.
### Notes
- The tester will only check for builtin commands and unrecognized commands in this stage.
- `type` itself is a shell builtin command, so `$ type type` should print `type is a shell builtin`.
marketing_md: |-
In this stage, you'll implement the `type` builtin command.
- slug: "mg5"
name: "The type builtin: executable files"
difficulty: medium
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. 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`.
### Tests
The tester will execute your program with a custom `PATH` like this:
```bash
PATH="/usr/bin:/usr/local/bin" ./your_program.sh
```
It'll then send a series of `type` commands to your shell:
```bash
$ type ls
ls is /usr/bin/ls
$ type valid_command
valid_command is /usr/local/bin/valid_command
$ type invalid_command
invalid_command: not found
$
```
The tester will check if the `type` command correctly identifies executable files in the PATH.
### 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.
marketing_md: |-
In this stage, you'll implement the `type` builtin command for your shell.
- slug: "ip1"
name: "Run a program"
difficulty: medium
description_md: |-
In this stage, you'll add support for running external programs with arguments.
External programs are located using the `PATH` environment variable, as described in previous stages.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a command that you need to execute:
```bash
$ program_1234 alice
Hello alice! The secret code is 1234.
```
The command (`program_1234`) in the example above will be present in `PATH` and will be an executable file.
The tester will check if your shell correctly executes the given command and prints the output.
### Notes
- The program name, arguments and the expected output will be random for each test case.
marketing_md: |-
In this stage, you'll implement the ability for your shell to run external programs with arguments.
- slug: "ei0"
primary_extension_slug: "navigation"
name: "The pwd builtin"
difficulty: easy
description_md: |-
In this stage, you'll implement the `pwd` builtin command.
[pwd](https://en.wikipedia.org/wiki/Pwd) stands for "print working directory".
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a `pwd` command to your shell:
```bash
$ pwd
/path/to/current/directory
$
```
The tester will check if the `pwd` command correctly prints the current working directory.
### Notes
- The `pwd` command must print the full absolute path of the current working directory.
marketing_md: |-
In this stage, you'll implement the ability for your shell to print the current working directory.
- slug: "ra6"
primary_extension_slug: "navigation"
name: "The cd builtin: Absolute paths"
difficulty: medium
description_md: |-
In this stage, you'll implement the `cd` builtin command to handle absolute paths.
The `cd` command is used to change the current working directory. `cd` can receive multiple
argument types. In this challenge we'll cover:
- Absolute paths, like `/usr/local/bin`. (**This stage**)
- Relative paths, like `./`, `../`, `./dir`. (Later stages)
- The `~` character, which stands for the user's home directory (Later stages)
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `cd` commands to your shell:
```bash
$ cd /usr/local/bin
$ pwd
/usr/local/bin
$ cd /does_not_exist
cd: /does_not_exist: No such file or directory
$
```
The tester will check if the `cd` command correctly changes the directory when a valid path is provided. It'll
also check whether the message `cd: <directory>: No such file or directory` is printed if the provided path is invalid.
### Notes
- The `cd` command doesn't print anything if the directory is changed successfully. The tester will use `pwd` to verify
the current working directory after using `cd`.
marketing_md: |-
In this stage, you'll implement the ability for your shell to run the `cd` builtin command with absolute paths.
- slug: "gq9"
primary_extension_slug: "navigation"
name: "The cd builtin: Relative paths"
difficulty: hard
description_md: |-
In this stage, you'll extend your `cd` builtin command to handle relative paths.
As a recap, `cd` can receive multiple argument types:
- Absolute paths, like `/usr/local/bin`. (Previous stages)
- Relative paths, like `./`, `../`, `./dir`. (**This stage**)
- The `~` character, which stands for the user's home directory (Later stages)
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `cd` commands to your shell:
```bash
$ cd /usr
$ pwd
/usr
$ cd ./local/bin
$ pwd
/usr/local/bin
$ cd ../../
$ pwd
/usr
$
```
The tester will check if the `cd` command correctly changes the directory when a valid path is provided. It'll
also check whether the message `cd: <directory>: No such file or directory` is printed if the provided path is invalid.
### Notes
- The actual directory names used will be random, so you can't hardcode the expected output.
- Relative paths like `./`, `../`, and more complex relative paths should be handled correctly.
- The `cd` command doesn't print anything if the directory is changed successfully. The tester will use `pwd` to verify
the current working directory after using `cd`.
marketing_md: |-
In this stage, you'll implement the ability for your shell to run the `cd` builtin command with relative paths.
- slug: "gp4"
primary_extension_slug: "navigation"
name: "The cd builtin: Home directory"
difficulty: medium
description_md: |-
In this stage, you'll extend your `cd` builtin command to handle the `~` character.
As a recap, `cd` can receive multiple argument types:
- Absolute paths, like `/usr/local/bin`. (Previous stages)
- Relative paths, like `./`, `../`, `./dir`. (Previous stages)
- The `~` character, which stands for the user's home directory (**This stage**)
The `~` character is 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. The home directory is specified by the
[`HOME`](https://unix.stackexchange.com/questions/123858/is-the-home-environment-variable-always-set-on-a-linux-system)
environment variable.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `cd` commands to your shell:
```bash
$ cd /usr/local/bin
$ pwd
/usr/local/bin
$ cd ~
$ pwd
/home/user
$
```
The tester will check if the `cd` command correctly changes the directory to the user's home directory when `~` is used.
### Notes
- The `pwd` command will be used to verify the current working directory after using `cd ~`.
- The home directory is specified by the `HOME` environment variable.
marketing_md: |-
In this stage, you'll implement the ability for your shell to run the `cd` builtin command with the `HOME` directory.
- slug: "ni6"
primary_extension_slug: "quoting"
name: "Single quotes"
difficulty: medium
description_md: |-
In this stage, you'll implement support for quoting with single quotes.
Enclosing characters in single quotes preserves the literal value of each character within the quotes. Read more about quoting with single quotes [here](https://www.gnu.org/software/bash/manual/bash.html#Single-Quotes).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `echo` commands to your shell:
```bash
$ echo 'shell hello'
shell hello
$ echo 'world test'
world test
$
```
The tester will check if the `echo` command correctly prints the quoted text.
Then it will also send a `cat` command, with the file name parameter enclosed in single quotes:
```bash
$ cat '/tmp/file name' '/tmp/file name with spaces'
content1 content2
```
The tester will check if the `cat` command correctly prints the file content.
marketing_md: |-
In this stage, you'll implement support for quoting with single quotes.
- slug: "tg6"
primary_extension_slug: "quoting"
name: "Double quotes"
difficulty: medium
description_md: |-
In this stage, you'll implement support for quoting with double quotes.
Enclosing characters in double quotes preserves the literal value of each character within the quotes except `\`, the backslash retains its special meaning when followed by `\`, `$`, `"` or newline. Read more about quoting with double quotes [here](https://www.gnu.org/software/bash/manual/bash.html#Double-Quotes).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `echo` commands to your shell:
```bash
$ echo "quz hello" "bar"
quz hello bar
$ echo "bar" "shell's" "foo"
bar shell's foo
$
```
The tester will check if the `echo` command correctly prints the quoted text.
Then it will also send a `cat` command, with the file name parameter enclosed in double quotes:
```bash
$ cat "/tmp/file name" "/tmp/'file name' with spaces"
content1 content2
```
The tester will check if the `cat` command correctly prints the file content.
marketing_md: |-
In this stage, you'll implement support for quoting with double quotes.
- slug: "yt5"
primary_extension_slug: "quoting"
name: "Backslash outside quotes"
difficulty: medium
description_md: |-
In this stage, you'll implement support for quoting with backslashes.
A non-quoted backslash `\` is treated as an escape character. It preserves the literal value of the next character. Read more about quoting with backslashes [here](https://www.gnu.org/software/bash/manual/bash.html#Escape-Character).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `echo` commands to your shell:
```bash
$ echo "before\ after"
before\ after
$ echo world\ \ \ \ \ \ script
world script
$
```
The tester will check if the `echo` command correctly prints the quoted text.
Then it will also send a `cat` command, with the file name parameters consisting of backslashes inside quotes:
```bash
$ cat "/tmp/file\\name" "/tmp/file\ name"
content1 content2
```
The tester will check if the `cat` command correctly prints the file content.
marketing_md: |-
In this stage, you'll implement support for quoting with backslashes only.
- slug: "le5"
primary_extension_slug: "quoting"
name: "Backslash within single quotes"
difficulty: medium
description_md: |-
In this stage, you'll implement support for quoting with backslashes within single quotes.
Enclosing characters in single quotes `'` preserves the literal value of each character within the quotes, even backslashes. Read more about quoting with backslashes within single quotes [here](https://www.gnu.org/software/bash/manual/bash.html#Single-Quotes).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `echo` commands to your shell:
```bash
$ echo 'shell\\\nscript'
shell\\\nscript
$ echo 'example\"testhello\"shell'
example\"testhello\"shell
$
```
The tester will check if the `echo` command correctly prints the quoted text.
Then it will also send a `cat` command, with the file name parameters consisting of backslashes inside single quotes:
```bash
$ cat "/tmp/file/'name'" "/tmp/file/'\name\'"
content1 content2
```
The tester will check if the `cat` command correctly prints the file content.
marketing_md: |-
In this stage, you'll implement support for quoting with backslashes within single quotes.
- slug: "gu3"
primary_extension_slug: "quoting"
name: "Backslash within double quotes"
difficulty: medium
description_md: |-
In this stage, you'll implement support for quoting with backslashes within double quotes.
Enclosing backslashes within double quotes `"` preserves the special meaning of the backslash, only when it is followed by `\`, `$`, `"` or newline. Read more about quoting with backslashes within double quotes [here](https://www.gnu.org/software/bash/manual/bash.html#Double-Quotes).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of `echo` commands to your shell:
```bash
$ echo "hello'script'\\n'world"
hello'script'\n'world
$ echo "hello\"insidequotes"script\"
hello"insidequotesscript"
$
```
The tester will check if the `echo` command correctly prints the quoted text.
Then it will also send a `cat` command, with the file name parameters consisting of backslashes inside double quotes:
```bash
$ cat "/tmp/"file\name"" "/tmp/"file name""
content1 content2
```
The tester will check if the `cat` command correctly prints the file content.
marketing_md: |-
In this stage, you'll implement support for quoting with backslashes within double quotes.
- slug: "qj0"
primary_extension_slug: "quoting"
name: "Executing a quoted executable"
difficulty: medium
description_md: |-
In this stage, you'll implement support for executing a quoted executable.
The tester will rename the `cat` executable to something containing spaces, quotes and backslashes.
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of commands to your shell, executing the renamed `cat` executable:
```bash
$ 'exe with "quotes"' file
content1
$ "exe with 'single quotes'" file
content2
```
The tester will check if the commands correctly execute the renamed `cat` executable, and that the output is correct.
marketing_md: |-
In this stage, you'll implement support for executing a quoted executable.
- slug: "jv1"
primary_extension_slug: "redirection"
name: "Redirect stdout"
difficulty: medium
description_md: |-
In this stage, you'll implement support for redirecting the output of a command to a file.
The `1>` operator is used to redirect the output of a command to a file.
But, as a special case, if the file descriptor is not specified before the operator `>`, the output is redirected to the standard output by default, so `>` is equivalent to `1>`.
Learn more about [Redirecting Output](https://www.gnu.org/software/bash/manual/bash.html#Redirecting-Output).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of commands to your shell, executing commands and redirecting their output to a file:
```bash
$ ls /tmp/baz > /tmp/foo/baz.md
$ cat /tmp/foo/baz.md
apple
blueberry
$ echo 'Hello James' 1> /tmp/foo/foo.md
$ cat /tmp/foo/foo.md
Hello James
$ cat /tmp/baz/blueberry nonexistent 1> /tmp/foo/quz.md
cat: nonexistent: No such file or directory
$ cat /tmp/foo/quz.md
blueberry
```
The tester will check if the commands correctly execute commands and redirect their output to a file as specified.
The file contents will also be checked for correctness.
marketing_md: |-
In this stage, you'll implement support for redirecting the output of a command to a file.
- slug: "vz4"
primary_extension_slug: "redirection"
name: "Redirect stderr"
difficulty: medium
description_md: |-
In this stage, you'll implement support for redirecting the standard error of a command to a file.
The `2>` operator is used to redirect the standard error of a command to a file.
Learn more about [Redirecting Stderr](https://www.gnu.org/software/bash/manual/bash.html#Redirecting-Output).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of commands to your shell, executing commands and redirecting their output to a file:
```bash
$ ls nonexistent 2> /tmp/quz/baz.md
$ cat /tmp/quz/baz.md
ls: cannot access 'nonexistent': No such file or directory
$ echo 'Maria file cannot be found' 2> /tmp/quz/foo.md
Maria file cannot be found
$ cat /tmp/bar/pear nonexistent 2> /tmp/quz/quz.md
pear
$ cat /tmp/quz/quz.md
cat: nonexistent: No such file or directory
```
The tester will check if the commands correctly execute commands and redirect their error message to a file as specified.
The file contents will also be checked for correctness.
marketing_md: |-
In this stage, you'll implement support for redirecting the standard error of a command to a file.
- slug: "el9"
primary_extension_slug: "redirection"
name: "Append stdout"
difficulty: medium
description_md: |-
In this stage, you'll implement support for appending the output of a command to a file.
The `1>>` operator is used to append the output of a command to a file.
As a special case, if the file descriptor is not specified before the operator `>>`, the output is redirected to the standard output by default, so `>>` is equivalent to `1>>`.
Learn more about [Appending Stdout](https://www.gnu.org/software/bash/manual/bash.html#Appending-Redirected-Output).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of commands to your shell, executing commands and appending their output to a file:
```bash
$ ls /tmp/baz >> /tmp/bar/bar.md
$ cat /tmp/bar/bar.md
apple
banana
blueberry
$ echo 'Hello Emily' 1>> /tmp/bar/baz.md
$ echo 'Hello Maria' 1>> /tmp/bar/baz.md
$ cat /tmp/bar/baz.md
Hello Emily
Hello Maria
$ echo "List of files: " > /tmp/bar/qux.md
$ ls /tmp/baz >> /tmp/bar/qux.md
$ cat /tmp/bar/qux.md
List of files:
apple
banana
blueberry
```
The tester will check if the commands correctly execute commands and append their output to a file as specified.
The file contents will also be checked for correctness.
marketing_md: |-
In this stage, you'll implement support for appending the output of a command to a file.
- slug: "un3"
primary_extension_slug: "redirection"
name: "Append stderr"
difficulty: medium
description_md: |-
In this stage, you'll implement support for appending the standard error of a command to a file.
The `2>>` operator is used to append the standard error of a command to a file.
Learn more about [Appending Stderr](https://www.gnu.org/software/bash/manual/bash.html#Appending-Redirected-Output).
### Tests
The tester will execute your program like this:
```bash
./your_program.sh
```
It'll then send a series of commands to your shell, executing commands and appending their standard error to a file:
```bash
$ ls nonexistent >> /tmp/foo/baz.md
ls: cannot access 'nonexistent': No such file or directory
$ ls nonexistent 2>> /tmp/foo/qux.md
$ cat /tmp/foo/qux.md
ls: cannot access 'nonexistent': No such file or directory
$ echo "James says Error" 2>> /tmp/foo/quz.md
James says Error
$ cat nonexistent 2>> /tmp/foo/quz.md
$ ls nonexistent 2>> /tmp/foo/quz.md
$ cat /tmp/foo/quz.md
cat: nonexistent: No such file or directory
ls: cannot access 'nonexistent': No such file or directory
```
The tester will check if the commands correctly execute commands and append their standard error to a file as specified.
The file contents will also be checked for correctness.
marketing_md: |-
In this stage, you'll implement support for appending the standard error of a command to a file.