Skip to content

Commit f770262

Browse files
authored
Merge branch 'master' into patch-3
2 parents 5190030 + 8f59828 commit f770262

61 files changed

Lines changed: 2301 additions & 1059 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sh/debian/configure.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,17 @@ elif [[ "--run" = "$1" ]]; then
388388
elif [[ "--deploy" = "$1" ]]; then
389389
deployCore
390390
deployPlatform
391-
echo -e "$(tput setaf 6)\nRepositories cloned and platform has been deployed successfully! $(tput sgr0)"
391+
echo -e "$(tput setaf 6)\nRepositories cloned and platform has been deployed successfully! $(tput sgr0)"
392392
exit 0
393393
elif [[ "--ssh-keys" = "$1" ]]; then
394394
sshKeyGen
395395
echo -e "$(tput setaf 5)\nSSH keys have been generated successfully! $(tput sgr0)"
396396
checkKeys
397397
exit 0
398+
elif [[ "--deploy-core" = "$1" ]]; then
399+
deployCore
400+
echo -e "$(tput setaf 5)\nRepositories cloned and core has been deployed successfully! $(tput sgr0)"
401+
exit 0
398402
elif [[ "--platform" = "$1" ]]; then
399403
clonePlatform
400404
echo -e "$(tput setaf 5)\nPlatform has been cloned successfully! $(tput sgr0)"

subjects/0-shell/README.md

Lines changed: 75 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,104 @@
1-
## 0-shell
1+
## 0-Shell
22

3-
### Objective
3+
### Overview
44

5-
The objective of this project is for you to create a simple [shell](https://en.wikipedia.org/wiki/Unix_shell).
5+
In this project, you'll build **0-shell**, a minimalist Unix-like shell implemented in **Rust**, designed to run core Unix commands using system calls—without relying on external binaries or built-in shells like `bash` or `sh`.
66

7-
Through the `0-shell` you will get to the core of the `Unix` system and explore an important part of this system’s API which is the process creation and synchronization.
8-
Executing a command inside a shell implies creating a new process, which execution and final state will be monitored by its parents processes. This set of functions will be the key to success for your project.
7+
Inspired by tools like [BusyBox](https://en.wikipedia.org/wiki/BusyBox), this project introduces you to key concepts in **Unix system programming**, including **process creation**, **command execution**, and **file system interaction**, all while leveraging Rust's safety and abstraction features to avoid manual memory management.
98

10-
For this project you will only have to create a simple `Unix shell` where you can run some of the most known commands. For this part of the project, no advanced functions, pipes or redirection will be asked, but you can add them if you like.
9+
### Role Play
1110

12-
### Instructions
11+
You are a **system-level developer** assigned to build a lightweight, standalone Unix shell for an embedded Linux environment. Your task is to create a shell that handles basic navigation, file manipulation, and process control—faithfully mimicking essential shell behaviors without relying on existing shell utilities.
1312

14-
- You must program a mini `Unix shell`, try to focus on something simple like [BusyBox](https://en.wikipedia.org/wiki/BusyBox).
15-
- This interpreter must display at least a simple `$` and wait until you type a command line which will be validated by pressing enter.
16-
- The `$` will be shown again only once the command has been completely executed.
17-
- The command lines are simple, you will not have pipes, redirection or any other advanced functions.
18-
- You must manage the errors, by displaying a message adapted to the error output.
19-
- You must implement the following commands:
20-
- `echo`
21-
- `cd`
22-
- `ls`, including the flags `-l`, `-a` and `-F`
23-
- `pwd`
24-
- `cat`
25-
- `cp`
26-
- `rm`, including the flag `-r`
27-
- `mv`
28-
- `mkdir`
29-
- `exit`
13+
### Learning Objectives
3014

31-
> The commands need to be implemented from scratch, without calling any external binaries.
15+
- Work with **file and directory operations**
16+
- Manage **user input and output** within a shell loop
17+
- Implement **robust error handling**
18+
- Gain experience in **Unix process and system call APIs**
3219

33-
- You must manage the program interruption `Ctrl + D`.
34-
- The project has to be written in a compiled language (like C, Rust, Go or other), **interpreted languages (like Perl and others) are not allowed**.
35-
- The code must respect the [good practices](https://public.01-edu.org/subjects/good-practices/)
20+
### Core Requirements
3621

37-
This project will help you learn about:
22+
Your minimalist shell must:
3823

39-
- Shell
40-
- Operating systems services
41-
- Command-line interfaces
42-
- Unix system
43-
- Process creation and synchronization
44-
- Commands syntax
45-
- Scripting language
24+
- Display a prompt (`$ `) and wait for user input
25+
- Parse and execute user commands
26+
- Return to the prompt only after command execution completes
27+
- Handle `Ctrl+D` (EOF) gracefully to exit the shell
4628

47-
### Bonus
29+
You must implement the following commands **from scratch**, using system-level Rust abstractions:
4830

49-
You can also do more bonus features like:
31+
- `echo`
32+
- `cd`
33+
- `ls` (supporting `-l`, `-a`, `-F`)
34+
- `pwd`
35+
- `cat`
36+
- `cp`
37+
- `rm` (supporting `-r`)
38+
- `mv`
39+
- `mkdir`
40+
- `exit`
5041

51-
- Implement the commands exclusively using `low-level system calls` avoiding built-in functions or libraries that abstract file operations.
42+
Additional constraints:
5243

53-
- Avoid High-Level Abstractions: Instead of using functions like the Go `os.Open, os.Remove, and io.Copy`, you would use system calls directly through the `syscall` package using `syscall.Open, syscall.Close, syscall.Read, syscall.Write, syscall.Unlink`.
44+
- Do **not** use any external binaries or system calls that spawn them
45+
- If a command is unrecognized, print:
46+
`Command '<name>' not found`
5447

55-
- Manage the interruption `Ctrl + C`
56-
- Auto complete when you are writing
57-
- Add piping
58-
- Add redirection
59-
- Have your path behind the `$` like (~/Desktop/0-shell $)
60-
- Add colors for the directories or errors
61-
- Other advanced commands you may like.
48+
### Constraints
6249

63-
### Usage
50+
- Only basic command syntax is required
51+
(No piping `|`, no redirection `>`, no globbing `*`, etc.)
52+
- Shell behavior should align with Unix conventions
53+
- Code must follow [good coding practices](https://public.01-edu.org/subjects/good-practices/)
6454

65-
```
55+
### Bonus Features
56+
57+
Implementing any of the following will be considered bonus:
58+
59+
- Handle `Ctrl+C` (SIGINT) without crashing the shell
60+
- Shell usability enhancements:
61+
- **Auto-completion**
62+
- **Command history**
63+
- **Prompt with current directory** (e.g., `~/projects/0-shell $`)
64+
- **Colorized output** for commands, directories, and errors
65+
- **Command chaining** with `;`
66+
- **Pipes** (`|`)
67+
- **I/O redirection** (`>`, `<`)
68+
- Support for environment variables (e.g. `$HOME`, `$PATH`)
69+
- A custom `help` command documenting built-in functionality
70+
71+
### Example Usage
72+
73+
```shell
6674
student$ ./0-shell
6775
$ cd dev
6876
$ pwd
69-
dev
77+
/dev
7078
$ ls -l
7179
total 0
72-
crw------- 1 root root 10, 58 fev 5 09:21 acpi_thermal_rel
73-
crw-r--r-- 1 root root 10, 235 fev 5 09:21 autofs
74-
drwxr-xr-x 2 root root 540 fev 5 09:21 block
75-
crw------- 1 root root 10, 234 fev 5 09:21 btrfs-control
76-
drwxr-xr-x 3 root root 60 fev 5 09:20 bus
77-
drwxr-xr-x 2 root root 4400 fev 5 09:21 char
78-
crw------- 1 root root 5, 1 fev 5 09:21 console
79-
lrwxrwxrwx 1 root root 11 fev 5 09:20 core -> /proc/kcore
80-
drwxr-xr-x 2 root root 60 fev 5 09:20 cpu
81-
crw------- 1 root root 10, 59 fev 5 09:21 cpu_dma_latency
80+
crw------- 1 root root 10, 58 Feb 5 09:21 acpi_thermal_rel
81+
crw-r--r-- 1 root root 10, 235 Feb 5 09:21 autofs
82+
drwxr-xr-x 2 root root 540 Feb 5 09:21 block
83+
...
8284
$ something
8385
Command 'something' not found
8486
$ echo "Hello There"
8587
Hello There
8688
$ exit
8789
student$
8890
```
91+
92+
### Evaluation Criteria
93+
94+
This project will be reviewed and graded based on the following:
95+
96+
- **Functionality**: Commands perform correctly and emulate standard Unix behavior
97+
- **Stability**: Shell handles user errors, invalid input, and edge cases without crashing
98+
99+
### Resources
100+
101+
- [man pages](https://man7.org/linux/man-pages/) (e.g., `man 2 open`, `man 2 execve`)
102+
- [Unix Shell - Wikipedia](https://en.wikipedia.org/wiki/Unix_shell)
103+
- [BusyBox](https://busybox.net/)
104+
- [Rust std::fs and std::process Docs](https://doc.rust-lang.org/std/)

subjects/0-shell/audit/README.md

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#### General
22

3-
###### Was the project written in a compiled programming language?
3+
###### Was the project written in Rust?
44

55
###### Are the commands mentioned in the subject implemented from scratch, without calling any external binaries?
66

7-
The use of execution commands (such as exec, system, os/exec, or similar functions) to call **external binaries** or utilities is strictly forbidden, as the project requires implementing all functionality from scratch without relying on external programs.
7+
The use of external binaries or system calls that spawn them is strictly forbidden, as the project requires implementing all functionality from scratch without relying on external programs.
88

99
#### Functional
1010

@@ -20,76 +20,74 @@ The use of execution commands (such as exec, system, os/exec, or similar functio
2020

2121
###### Can you confirm that the interpreter only validates the command if you press enter?
2222

23-
##### Try to run the command `"exit"`.
23+
##### Try to run the command `exit`.
2424

2525
###### Can you confirm that the interpreter terminates properly and gives back the parent's shell?
2626

27-
##### Try to run the command `"echo "something!""`. Do the same in your computer terminal.
27+
##### Try to run the command `echo "something!"`. Do the same in your computer terminal.
2828

2929
###### Can you confirm that the displayed message of the project is exactly the same as the computer terminal?
3030

31-
##### Try to run the command `"echo something else"` (without double quotes). Do the same in your computer terminal.
31+
##### Try to run the command `echo something else` (without double quotes). Do the same in your computer terminal.
3232

3333
###### Can you confirm that the displayed message of the project is exactly the same as the computer terminal?
3434

35-
##### Try to run the command `"pwd"`.
35+
##### Try to run the command `pwd`.
3636

3737
###### Can you confirm that the interpreter displayed the current path?
3838

39-
##### Try to open the project and create a parent folder with two children folders using the command "mkdir". Then enter the parent folder and do "pwd".
39+
##### Try to open the project and create a parent folder with two children folders using the command `mkdir`. Then enter the parent folder and do `pwd`.
4040

4141
###### Can you confirm that the interpreter displayed the current path?
4242

43-
##### Try to enter a directory of your choice by using the command `"cd dir/of/your/choice"`.
43+
##### Try to enter a directory of your choice by using the command `cd dir/of/your/choice`.
4444

45-
###### Can you confirm that the interpreter took you to the correct path? Use `"pwd"` to confirm.
45+
###### Can you confirm that the interpreter took you to the correct path? Use `pwd` to confirm.
4646

47-
##### Try to run only the command `"cd"`.
47+
##### Try to run only the command `cd`.
4848

49-
###### Can you confirm that the interpreter took you to the users home folder? Use `"pwd"` to confirm.
49+
###### Can you confirm that the interpreter took you to the users home folder? Use `pwd` to confirm.
5050

51-
##### Try to run the command `"ls"` in a directory at your choice. Do the same in your computer terminal.
51+
##### Try to run the command `ls` in a directory at your choice. Do the same in your computer terminal.
5252

53-
###### Can you confirm that the output is the same in the project and in your computer terminal?
53+
###### Can you confirm that the output is similar in the project and in your computer terminal?
5454

55-
##### Try to run the command `"ls -l -a -F"` in a directory at your choice. Do the same in your computer terminal.
55+
##### Try to run the command `ls -l -a -F` in a directory at your choice. Do the same in your computer terminal.
5656

57-
###### Can you confirm that the output is the same in the project and in your computer terminal?
57+
###### Can you confirm that the output is similar in the project and in your computer terminal?
5858

59-
##### Try to run the commands `"mkdir new_folder1"` and `"mkdir new_folder2"` in a directory of your choice.
59+
##### Try to run the commands `mkdir new_folder1` and `mkdir new_folder2` in a directory of your choice.
6060

61-
###### Can you confirm that the directory `new_folder1` and `new_folder2` were created?
61+
###### Can you confirm that the directories `new_folder1` and `new_folder2` were created?
6262

63-
##### Create a document inside the `new_folder1` called `new_doc.txt` with some random text inside. Try to run the command `"cp new_doc.txt ../folder2"` to copy the document to the folder `new_folder2`.
63+
##### Create a document inside the `new_folder1` called `new_doc.txt` with some random text inside. Try to run the command `cp new_doc.txt ../folder2` to copy the document to the folder `new_folder2`.
6464

6565
###### Can you confirm that the document `new_doc.txt` is inside the `new_folder2`?
6666

67-
##### Try to run the command `"cat new_folder1/new_doc"`. Do the same in your computer terminal.
67+
##### Try to run the command `cat new_folder1/new_doc`. Do the same in your computer terminal.
6868

6969
###### Can you confirm that the output is the same in the project and in your computer terminal?
7070

71-
##### Try to run the commands `"mv new_folder2 new_folder1"` to move the directory `new_folder2` inside of the directory `new_folder1`.
71+
##### Try to run the commands `mv new_folder2 new_folder1` to move the directory `new_folder2` inside of the directory `new_folder1`.
7272

7373
###### Can you confirm that the directory `new_folder2` is inside of the directory `new_folder1`?
7474

75-
##### Try to run the command `"rm -r new_folder1"` to remove what was created above.
75+
##### Try to run the command `rm -r new_folder1` to remove what was created above.
7676

7777
###### Can you confirm that the directory `new_folder1` was removed?
7878

7979
#### Bonus
8080

81-
###### + Did the student implemented the commands exclusively using `low-level system calls` avoiding built-in functions or libraries that abstract file operations?
82-
83-
###### +Did the student added auto complete when you are writing the commands?
81+
###### +Did the student handle `Ctrl + C` gracefully?
8482

85-
###### +Did the student added piping?
83+
###### +Did the student add auto-completion when writing a command?
8684

87-
###### +Did the student managed the `Ctrl + C`?
85+
###### +Did the student implement piping?
8886

89-
###### +Did the student added colors to the errors or directories?
87+
###### +Did the student add colors to the errors or directories?
9088

91-
###### +Did the student added redirection?
89+
###### +Did the student implement redirection?
9290

93-
###### +Did the student added the current path behind the `$`?
91+
###### +Did the student display the current directory in the prompt?
9492

95-
###### +Did the student added any other features or commands to the project?
93+
###### +Did the student add any other features or commands to the project?

subjects/card_deck/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ fn main() {
6666
suit: Suit::random(),
6767
};
6868

69-
println!("Your card is {:?}", your_card);
69+
println!("Your card is {:?}", &your_card);
7070

71-
if card_deck::winner_card(your_card) {
71+
if card_deck::winner_card(&your_card) {
7272
println!("You are the winner!");
7373
}
7474
}

0 commit comments

Comments
 (0)