{"id":25201410,"url":"https://github.com/msaf9/custom-shell","last_synced_at":"2025-04-04T20:37:13.128Z","repository":{"id":276384732,"uuid":"925939315","full_name":"msaf9/custom-shell","owner":"msaf9","description":"The shell supports fundamental features such as executing commands, handling background processes using \u0026, and enabling input/output redirection with \u003c and \u003e. Additionally, it supports piped commands (|) to facilitate command chaining. ","archived":false,"fork":false,"pushed_at":"2025-02-07T21:56:04.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T22:34:06.783Z","etag":null,"topics":["c-programming-language","shell"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msaf9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-02T05:45:54.000Z","updated_at":"2025-02-07T21:56:08.000Z","dependencies_parsed_at":"2025-02-07T22:44:10.532Z","dependency_job_id":null,"html_url":"https://github.com/msaf9/custom-shell","commit_stats":null,"previous_names":["msaf9/custom-shell"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf9%2Fcustom-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf9%2Fcustom-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf9%2Fcustom-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaf9%2Fcustom-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msaf9","download_url":"https://codeload.github.com/msaf9/custom-shell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249262,"owners_count":20908205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-programming-language","shell"],"created_at":"2025-02-10T05:15:44.057Z","updated_at":"2025-04-04T20:37:13.103Z","avatar_url":"https://github.com/msaf9.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Custom Shell\nDesigned to provide a lightweight yet functional command-line interface.\n\n## Table of Contents\n- [Overview](#overview)\n- [Features](#features)\n    - [1. Command Execution](#1-command-execution)\n    - [2. Background Execution](#2-background-execution)\n    - [3. Input and Output Redirection](#3-input-and-output-redirection)\n    - [4. Piped Commands](#4-piped-commands)\n    - [5. Built-in Commands](#5-built-in-commands)\n- [Compilation and Execution](#compilation-and-execution)\n    - [Compiling the Shell](#compiling-the-shell)\n    - [Running the Shell](#running-the-shell)\n- [Usage](#usage)\n- [Code Structure](#code-structure)\n    - [Files](#files)\n    - [Functions](#functions)\n- [Example Commands](#example-commands)\n- [Limitations](#limitations)\n- [Future Enhancements](#future-enhancements)\n- [License](#license)\n\n## Overview\nThis project is a simple custom shell implemented in C. The shell supports various features such as:\n\n- Command execution\n- Background execution using `\u0026`\n- Input redirection using `\u003c`\n- Output redirection using `\u003e`\n- Piped commands using `|`\n- Built-in commands: `cd`, `exit`, and `history`\n- Command history tracking\n- Re-execution of commands from history using `!\u003cnumber\u003e`\n\n## Features\n### 1. Command Execution\nThe shell allows users to execute standard shell commands by typing them into the prompt.\n\n### 2. Background Execution\nAppending `\u0026` to a command runs it in the background.\n\n### 3. Input and Output Redirection\n- `\u003c filename` redirects input from a file.\n- `\u003e filename` redirects output to a file.\n\n### 4. Piped Commands\nThe shell supports multiple piped commands (e.g., `ls | grep txt`).\n\n### 5. Built-in Commands\n- `cd \u003cdirectory\u003e`: Changes the current working directory.\n- `exit`: Exits the shell.\n- `history`: Displays a list of previously executed commands.\n- `!\u003cnumber\u003e`: Re-executes a command from history.\n\n## Compilation and Execution\n### Compiling the Shell\n```sh\ngcc src/Shell.c -o Shell\n```\n\n### Running the Shell\n```sh\n./Shell\n```\n\n## Usage\n1. Run the shell using `./mysh`.\n2. Enter commands at the `mysh\u003e` prompt.\n3. Use built-in commands as needed.\n4. Use `CTRL+C` to terminate a running foreground process.\n\n## Code Structure\n### Files\n- `shell.c`: Main source file for the shell implementation.\n- `shell.h`: Header file containing function declarations and constants.\n- `Makefile`: Automates the build process.\n\n### Functions\n- `add_to_history`: Stores commands in history.\n- `print_history`: Displays command history.\n- `parse_input`: Splits input into commands, supporting pipes.\n- `parse_command`: Parses a command, handling arguments and redirections.\n- `execute_command`: Runs a command with optional redirection.\n- `execute_piped_commands`: Executes a sequence of piped commands.\n- `handle_builtin`: Processes built-in commands like `cd`, `exit`, and `history`.\n- `main`: Main loop handling user input and executing commands.\n\n## Example Commands\n```sh\nmysh\u003e ls -l\nmysh\u003e echo \"Hello World\" \u003e output.txt\nmysh\u003e cat \u003c output.txt\nmysh\u003e history\nmysh\u003e !2  # Re-executes the second command from history\nmysh\u003e ls | grep .c\nmysh\u003e sleep 5 \u0026  # Runs in the background\n```\n\n## Limitations\n- No advanced error handling for deeply nested pipes.\n- Limited support for environment variable expansion.\n- No tab-completion or advanced interactive features.\n- Background processes do not support job control.\n\n## Future Enhancements\n- Implement environment variable support.\n- Add tab-completion.\n- Improve error handling and reporting.\n- Support job control for background processes.\n\n## License\nThis project is released under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaf9%2Fcustom-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsaf9%2Fcustom-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaf9%2Fcustom-shell/lists"}