seed: curriculum content
This commit is contained in:
48
1.solar-system/1.welcome/07.the-editor/index.md
Normal file
48
1.solar-system/1.welcome/07.the-editor/index.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
type: challenge
|
||||
title: "The Editor"
|
||||
xp: 50
|
||||
duration: 25
|
||||
difficulty: 2
|
||||
---
|
||||
|
||||
# The Editor
|
||||
|
||||
> **[INCOMING — Mission Control, Earth]**
|
||||
>
|
||||
> Cadet, single-line `echo` works for short messages. Real files
|
||||
> need multiple lines. Two options:
|
||||
>
|
||||
> - Multiple `echo` lines, each with its own redirect (use `>>` after
|
||||
> the first one to append)
|
||||
> - A *heredoc* — write a whole block in one go:
|
||||
>
|
||||
> ```bash
|
||||
> cat > journal.md <<EOF
|
||||
> line one
|
||||
> line two
|
||||
> EOF
|
||||
> ```
|
||||
>
|
||||
> Write a script that creates `journal.md` containing exactly:
|
||||
>
|
||||
> ```
|
||||
> # Cadet Log — Day 1
|
||||
>
|
||||
> Today I learned to navigate the shell.
|
||||
> Tomorrow I will write code.
|
||||
> ```
|
||||
>
|
||||
> Mind the empty line between the header and the body.
|
||||
>
|
||||
> [END TRANSMISSION]
|
||||
|
||||
## Your Task
|
||||
|
||||
In `starter/starter.sh`, produce `journal.md` with the exact content
|
||||
above.
|
||||
|
||||
## Objectives
|
||||
|
||||
- `journal.md` exists
|
||||
- Contents match the template exactly (4 lines + the blank line)
|
||||
19
1.solar-system/1.welcome/07.the-editor/starter/starter.sh
Normal file
19
1.solar-system/1.welcome/07.the-editor/starter/starter.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# The Editor — write a multi-line journal entry.
|
||||
#
|
||||
# Your script must create a file `journal.md` containing exactly:
|
||||
#
|
||||
# # Cadet Log — Day 1
|
||||
#
|
||||
# Today I learned to navigate the shell.
|
||||
# Tomorrow I will write code.
|
||||
#
|
||||
# Note the empty line between the header and the body.
|
||||
#
|
||||
# A heredoc writes multiple lines at once:
|
||||
#
|
||||
# cat > journal.md <<EOF
|
||||
# ...lines here...
|
||||
# EOF
|
||||
|
||||
# Your code here.
|
||||
19
1.solar-system/1.welcome/07.the-editor/testing/test.sh
Normal file
19
1.solar-system/1.welcome/07.the-editor/testing/test.sh
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
bash solution.sh > /dev/null 2>&1
|
||||
|
||||
EXPECTED=$(cat <<'EXP'
|
||||
# Cadet Log — Day 1
|
||||
|
||||
Today I learned to navigate the shell.
|
||||
Tomorrow I will write code.
|
||||
EXP
|
||||
)
|
||||
|
||||
N=0
|
||||
report() { N=$((N+1)); if [ "$1" = "0" ]; then echo "ok $N - $2"; else echo "not ok $N - $2"; fi; }
|
||||
|
||||
[ -f journal.md ]; report $? "journal.md exists"
|
||||
|
||||
ACTUAL=$(cat journal.md 2>/dev/null)
|
||||
ACTUAL="${ACTUAL%$'\n'}"
|
||||
[ "$ACTUAL" = "$EXPECTED" ]; report $? "journal.md matches the template exactly"
|
||||
Reference in New Issue
Block a user