https://github.com/minightdev/simple_shell
A custom shell implemented in C that supports executing commands, handling environment variables, and built-in commands like setenv, unsetenv, exit, and echo. It provides a basic interactive shell interface where you can enter commands and receive output.
https://github.com/minightdev/simple_shell
c-lang custom-shell shell
Last synced: 9 months ago
JSON representation
A custom shell implemented in C that supports executing commands, handling environment variables, and built-in commands like setenv, unsetenv, exit, and echo. It provides a basic interactive shell interface where you can enter commands and receive output.
- Host: GitHub
- URL: https://github.com/minightdev/simple_shell
- Owner: MinightDev
- Created: 2023-08-15T17:18:53.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-08-24T01:11:38.000Z (over 2 years ago)
- Last Synced: 2025-04-07T23:13:26.944Z (12 months ago)
- Topics: c-lang, custom-shell, shell
- Language: C
- Homepage:
- Size: 29.3 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Authors: AUTHORS
Awesome Lists containing this project
README
# Custom Shell
A custom shell implemented in C that supports executing commands, handling environment variables, and built-in commands like `setenv`, `unsetenv`, `exit`, and `echo`. It provides a basic interactive shell interface where you can enter commands and receive output.
## Features
- Execute external commands and handle built-in commands.
- Environment variable management with `setenv` and `unsetenv` commands.
- Handle special environment variables like `$?` and `$$`.
- Replace environment variables in strings using the `$` syntax.
- Basic error handling and memory management.
## Usage
The custom shell supports basic shell commands and built-in commands. You can execute external commands and use the built-in commands by typing them into the shell.
## Compiling
To compile the shell, run
```bash
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o hsh
```
Example of built-in commands:
- `echo [text]`: Display text to the console.
- `setenv [variable] [value]`: Set or update an environment variable.
- `unsetenv [variable]`: Remove an environment variable.
- `exit [status]`: Exit the shell with an optional status code.
To execute external commands, simply type the command name followed by any required arguments.
## Notes
- Built-in commands are handled within the shell program.
- Environment variable expansion is supported using `$VARNAME` syntax.
Feel free to explore this custom shell implementation according to your needs!