Skip to content

Commit 78c23cf

Browse files
authored
Merge pull request #98 from codecrafters-io/andy/tweak
[History Persistence] Fix examples in instructions and add notes
2 parents 23b6bf5 + 7f969d2 commit 78c23cf

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

course-definition.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,9 +1315,9 @@ stages:
13151315
[history](https://www.gnu.org/software/bash/manual/html_node/Bash-History-Builtins.html#index-history) as a shell builtin that lists previously executed commands. Example usage:
13161316
```bash
13171317
$ history
1318-
1 previous_command_1
1319-
2 previous_command_2
1320-
3 history
1318+
1 previous_command_1
1319+
2 previous_command_2
1320+
3 history
13211321
```
13221322
13231323
### Tests
@@ -1549,6 +1549,7 @@ stages:
15491549
```txt
15501550
echo hello
15511551
echo world
1552+
<|EMPTY LINE|>
15521553
```
15531554
15541555
The tester will execute your program like this:
@@ -1562,15 +1563,16 @@ stages:
15621563
```bash
15631564
$ history -r <path_to_history_file>
15641565
$ history
1565-
1 echo hello
1566-
2 echo world
1567-
3 history -r <path_to_history_file>
1568-
4 history
1566+
1 history -r <path_to_history_file>
1567+
2 echo hello
1568+
3 echo world
1569+
4 history
15691570
$
15701571
```
15711572
15721573
### Notes
15731574
- The tester will expect the history commands to also be present in the history list.
1575+
- `history -r` should append the history file's contents to the history list in memory.
15741576
15751577
marketing_md: |-
15761578
In this stage, you'll implement support for reading history from a file.
@@ -1600,18 +1602,20 @@ stages:
16001602
$ history -w <path_to_history_file>
16011603
$
16021604
```
1603-
1605+
16041606
The tester will then expect the history file's contents to look like:
16051607
16061608
```txt
16071609
echo hello
16081610
echo world
16091611
history -w <path_to_history_file>
1612+
<|EMPTY LINE|>
16101613
```
16111614
16121615
### Notes
16131616
- If the file doesn't exist when running `history -w`, your shell should create the file and then write the commands to it.
16141617
- The tester will expect the `history -w` command to also be present in the history file.
1618+
- The history file should include a trailing newline character (displayed as an empty line).
16151619
16161620
marketing_md: |-
16171621
In this stage, you'll implement support for writing history to a file.
@@ -1626,10 +1630,11 @@ stages:
16261630
### Tests
16271631
16281632
The tester will write the following commands to the history file:
1629-
1633+
16301634
```txt
16311635
echo initial_command_1
16321636
echo initial_command_2
1637+
<|EMPTY LINE|>
16331638
```
16341639
16351640
The tester will execute your program like this:
@@ -1654,6 +1659,7 @@ stages:
16541659
echo initial_command_2
16551660
echo new_command
16561661
history -a <path_to_history_file>
1662+
<|EMPTY LINE|>
16571663
```
16581664
16591665
### Notes
@@ -1683,6 +1689,7 @@ stages:
16831689
```txt
16841690
echo hello
16851691
echo world
1692+
<|EMPTY LINE|>
16861693
```
16871694
16881695
The tester will execute your program like this:
@@ -1695,9 +1702,9 @@ stages:
16951702
16961703
```bash
16971704
$ history
1698-
1 echo hello
1699-
2 echo world
1700-
3 history
1705+
1 echo hello
1706+
2 echo world
1707+
3 history
17011708
$
17021709
```
17031710
@@ -1728,13 +1735,14 @@ stages:
17281735
world
17291736
$ exit 0
17301737
```
1731-
1738+
17321739
The tester will then expect the history file's contents to look like:
17331740
17341741
```txt
17351742
echo hello
17361743
echo world
17371744
exit 0
1745+
<|EMPTY LINE|>
17381746
```
17391747
17401748
marketing_md: |-
@@ -1754,6 +1762,7 @@ stages:
17541762
```txt
17551763
echo initial_command_1
17561764
echo initial_command_2
1765+
<|EMPTY LINE|>
17571766
```
17581767
17591768
The tester will execute your program like this:
@@ -1777,7 +1786,8 @@ stages:
17771786
echo initial_command_2
17781787
echo new_command
17791788
exit 0
1789+
<|EMPTY LINE|>
17801790
```
17811791
17821792
marketing_md: |-
1783-
In this stage, you'll implement support for appending the in-memory history to the history file when exiting.
1793+
In this stage, you'll implement support for appending the in-memory history to the history file when exiting.

0 commit comments

Comments
 (0)