This Rust application is a simple shell that accepts basic commands like cd, pwd, ls, and exit. It's designed to demonstrate how to interact with the system's environment, file system, and processes in Rust.
- Change Directory (
cd): Changes the current working directory of the shell. - Print Working Directory (
pwd): Prints the current working directory. - List (
ls): Lists the contents of the current directory. - Exit (
exit): Exits the shell.
- Ensure you have Rust installed on your system. If not, you can install it from the official website.
- Clone this repository or copy the source code into a
.rsfile. - Navigate to the directory containing the source code in your terminal.
- Compile the code with
rustc <filename>.rs. - Run the compiled executable with
./<filename>on Unix/Linux/macOS or<filename>.exeon Windows.
After running the application, you will be presented with a prompt (>). You can type any of the supported commands (cd, pwd, ls, exit) followed by Enter.
Example:
pwd
/Users/username/projects/rust-shell - The
lscommand currently prints raw metadata about directory entries, which might be less readable compared to the standardlscommand output. - Error handling is minimal, primarily using
unwrap()for simplicity, which may cause the program to panic on errors instead of handling them gracefully.