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
Copy file name to clipboardExpand all lines: course-definition.yml
+227-1Lines changed: 227 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,13 @@ extensions:
86
86
87
87
Pipelines allow you to connect multiple commands together, so the output of one command becomes the input of the next command.
88
88
89
+
- slug: "history"
90
+
name: "History"
91
+
description_markdown: |
92
+
In this challenge extension, you'll add support for viewing and recalling previously entered commands using the `history` builtin.
93
+
94
+
History allows you to view and recall previously entered commands. Also, use it to re-run previous commands using the UP and DOWN arrow keys.
95
+
89
96
stages:
90
97
- slug: "oo8"
91
98
name: "Print a prompt"
@@ -581,7 +588,7 @@ stages:
581
588
582
589
### Notes
583
590
584
-
- The `cat` command is an executable available on most systems, so there’s no need to implement it yourself.
591
+
- The `cat` command is an executable available on most systems, so there's no need to implement it yourself.
585
592
586
593
marketing_md: |-
587
594
In this stage, you'll implement support for quoting with single quotes.
@@ -1288,3 +1295,222 @@ stages:
1288
1295
- Proper process cleanup and waiting are crucial.
1289
1296
marketing_md: |-
1290
1297
Implement support for multi-command pipelines like `command1 | command2 | command3`.
1298
+
1299
+
- slug: "bq4"
1300
+
primary_extension_slug: "history"
1301
+
name: "The history builtin"
1302
+
difficulty: easy
1303
+
description_md: |-
1304
+
In this stage, you'll add support for [history](https://www.gnu.org/software/bash/manual/html_node/Bash-History-Builtins.html#index-history) as a shell builtin.
1305
+
1306
+
### Tests
1307
+
1308
+
The tester will execute your program like this:
1309
+
1310
+
```bash
1311
+
./your_program.sh
1312
+
```
1313
+
1314
+
The tester will then execute the `type history` command.
1315
+
1316
+
```bash
1317
+
$ type history
1318
+
history is a shell builtin
1319
+
$
1320
+
```
1321
+
1322
+
The tester will then execute the `type history` command and expect the output to be `history is a shell builtin`.
1323
+
1324
+
### Notes
1325
+
1326
+
- For now we're just testing that the `type` builtin identifies `history` as a valid builtin.
1327
+
- We'll handle the actual implementation of the `history` builtin in later stages.
1328
+
1329
+
marketing_md: |-
1330
+
In this stage, you'll add support for the `history` builtin command in `type`.
1331
+
1332
+
- slug: "yf5"
1333
+
primary_extension_slug: "history"
1334
+
name: "Listing history"
1335
+
difficulty: medium
1336
+
description_md: |-
1337
+
In this stage, you'll implement the `history` builtin.
1338
+
1339
+
### Tests
1340
+
1341
+
The tester will execute your program like this:
1342
+
1343
+
```bash
1344
+
./your_program.sh
1345
+
```
1346
+
1347
+
It will then send multiple commands to your shell, followed by the `history` command:
1348
+
1349
+
```bash
1350
+
$ echo hello
1351
+
hello
1352
+
$ echo world
1353
+
world
1354
+
$ invalid_command
1355
+
invalid_command: command not found
1356
+
$ history
1357
+
1 echo hello
1358
+
2 echo world
1359
+
3 invalid_command
1360
+
4 history
1361
+
$
1362
+
```
1363
+
1364
+
The tester will then execute the `history` command and expect a history list with the commands that were executed, formatted and indexed like in the example above.
1365
+
1366
+
### Notes
1367
+
1368
+
- Some shells like *zsh* don't add the `history` command to the history list, but the tester expects it to be present.
1369
+
1370
+
marketing_md: |-
1371
+
In this stage, you'll implement the `history` builtin.
1372
+
1373
+
- slug: "ag6"
1374
+
primary_extension_slug: "history"
1375
+
name: "Limiting history entries"
1376
+
difficulty: medium
1377
+
description_md: |-
1378
+
In this stage, you'll add support for limiting history entries using the `history <n>` syntax.
1379
+
1380
+
### Tests
1381
+
1382
+
The tester will execute your program like this:
1383
+
1384
+
```bash
1385
+
./your_program.sh
1386
+
```
1387
+
1388
+
It will then send multiple commands to your shell, followed by the `history <n>` command:
1389
+
1390
+
```bash
1391
+
$ echo hello
1392
+
hello
1393
+
$ echo world
1394
+
world
1395
+
$ invalid_command
1396
+
invalid_command: command not found
1397
+
$ history 2
1398
+
3 invalid_command
1399
+
4 history 2
1400
+
$
1401
+
```
1402
+
1403
+
The tester will then execute the `history <n>` command and expect the history list to be limited to the last `n` commands.
1404
+
1405
+
### Notes
1406
+
1407
+
- The tester expects the history command to be present in the history list.
1408
+
1409
+
marketing_md: |-
1410
+
In this stage, you'll implement support for limiting history entries.
1411
+
1412
+
- slug: "rh7"
1413
+
primary_extension_slug: "history"
1414
+
name: "Up-arrow navigation"
1415
+
difficulty: medium
1416
+
description_md: |-
1417
+
In this stage, you'll add support for recalling history with the up arrow key.
1418
+
1419
+
### Tests
1420
+
1421
+
The tester will execute your program like this:
1422
+
1423
+
```bash
1424
+
./your_program.sh
1425
+
```
1426
+
1427
+
It will then send multiple commands to your shell, followed by the up arrow to recall the history:
1428
+
1429
+
```bash
1430
+
$ echo hello
1431
+
hello
1432
+
$ echo world
1433
+
world
1434
+
<UP ARROW>
1435
+
$ echo world
1436
+
<UP ARROW>
1437
+
$ echo hello
1438
+
```
1439
+
1440
+
The tester will execute some commands and then press the up arrow key to recall the history.
1441
+
1442
+
marketing_md: |-
1443
+
In this stage, you'll implement support for recalling history with the up arrow key.
1444
+
1445
+
- slug: "vq0"
1446
+
primary_extension_slug: "history"
1447
+
name: "Down-arrow navigation"
1448
+
difficulty: medium
1449
+
description_md: |-
1450
+
In this stage, you'll add support for recalling history with the down arrow key.
1451
+
1452
+
### Tests
1453
+
1454
+
The tester will execute your program like this:
1455
+
1456
+
```bash
1457
+
./your_program.sh
1458
+
```
1459
+
1460
+
It will then send multiple commands to your shell, followed by the up and then down arrow keys to recall the history:
1461
+
1462
+
```bash
1463
+
$ echo hello
1464
+
hello
1465
+
$ echo world
1466
+
world
1467
+
<UP ARROW>
1468
+
$ echo world
1469
+
<UP ARROW>
1470
+
$ echo hello
1471
+
<DOWN ARROW>
1472
+
$ echo world
1473
+
```
1474
+
1475
+
The tester will execute some commands and then press the up and then down arrow keys to recall the history.
1476
+
1477
+
marketing_md: |-
1478
+
In this stage, you'll implement support for recalling history with the down arrow key.
1479
+
1480
+
- slug: "dm2"
1481
+
primary_extension_slug: "history"
1482
+
name: "Command Execution after Arrow Navigation"
1483
+
difficulty: medium
1484
+
description_md: |-
1485
+
In this stage, you'll implement support for being able to press enter to execute a command recalled using UP-DOWN arrows.
1486
+
1487
+
### Tests
1488
+
1489
+
The tester will execute your program like this:
1490
+
1491
+
```bash
1492
+
./your_program.sh
1493
+
```
1494
+
1495
+
It will then send multiple commands to your shell, followed by the up and then down arrow keys to recall the history:
1496
+
1497
+
```bash
1498
+
$ echo hello
1499
+
hello
1500
+
$ echo world
1501
+
world
1502
+
<UP ARROW>
1503
+
$ echo world
1504
+
<UP ARROW>
1505
+
$ echo hello
1506
+
<DOWN ARROW>
1507
+
$ echo world
1508
+
<ENTER>
1509
+
world
1510
+
$
1511
+
```
1512
+
1513
+
The tester will execute some commands and then press the up and then down arrow keys to recall the history and then press enter to execute the command arrived.
1514
+
1515
+
marketing_md: |-
1516
+
In this stage, you'll implement support for being able to press enter to execute a command recalled using UP-DOWN arrows.
0 commit comments