{"id":25293843,"url":"https://github.com/srujayreddy/custom-unix-shell","last_synced_at":"2025-04-06T19:55:00.848Z","repository":{"id":272884278,"uuid":"918000632","full_name":"SrujayReddy/Custom-Unix-Shell","owner":"SrujayReddy","description":"A custom Unix shell implemented in C, featuring piping, redirection, command history, and process management. Built to explore system-level programming concepts.","archived":false,"fork":false,"pushed_at":"2025-01-18T04:23:21.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T01:55:37.564Z","etag":null,"topics":["academic-project","automation-scripts","c-programming","concurrent-processing","custom-shell","piping-redirection","process-management","systems-programming","unix-shell"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SrujayReddy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-17T03:47:46.000Z","updated_at":"2025-01-18T04:23:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"2c6cc8b2-6f76-449c-9dd2-9319d55ab541","html_url":"https://github.com/SrujayReddy/Custom-Unix-Shell","commit_stats":null,"previous_names":["srujayreddy/custom-unix-shell"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SrujayReddy%2FCustom-Unix-Shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SrujayReddy%2FCustom-Unix-Shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SrujayReddy%2FCustom-Unix-Shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SrujayReddy%2FCustom-Unix-Shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SrujayReddy","download_url":"https://codeload.github.com/SrujayReddy/Custom-Unix-Shell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247543601,"owners_count":20955865,"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":["academic-project","automation-scripts","c-programming","concurrent-processing","custom-shell","piping-redirection","process-management","systems-programming","unix-shell"],"created_at":"2025-02-13T01:55:39.180Z","updated_at":"2025-04-06T19:55:00.843Z","avatar_url":"https://github.com/SrujayReddy.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Custom Unix Shell (`wsh`)\n\n## Overview\n\n`wsh` is a custom Unix shell that replicates and extends the functionality of traditional Unix/Linux shells. It was developed as part of the **CS 537: Introduction to Operating Systems** course at the University of Wisconsin–Madison. This project provides hands-on experience with process management, inter-process communication, and system-level programming.\n\n---\n\n## Key Features\n\n- **Command Execution**: Run standard Unix/Linux commands and scripts seamlessly.  \n- **Command History**: Store and reuse previously executed commands for enhanced usability.  \n- **Environment Variables**: Manage local variables with a custom-built hashmap.  \n- **I/O Redirection**: Support for input/output redirection and piping between processes.  \n- **Batch Scripting**: Execute `.wsh` script files for task automation.  \n\n---\n\n## Purpose\n\nThis project was designed to:\n- Deepen understanding of operating system concepts through practical implementation.\n- Master system calls like `fork()`, `execvp()`, and `pipe()`.\n- Improve resource utilization techniques and process management.\n- Enhance skills in C programming and Unix/Linux system programming.\n\n---\n\n## Technical Implementation\n\n### Command History\n\nThe shell uses a **circular array** to manage command history efficiently, storing a fixed number of commands and discarding the oldest as new commands are added.\n\n### Environment Variables\n\nEnvironment variables are handled using a **hashmap with chaining** to resolve collisions, enabling quick and efficient storage and retrieval of local variables.\n\n### Piping and I/O Redirection\n\nThe `pipe()` system call is used for inter-process communication. More advanced execution scenarios are supported through redirection of standard input (`stdin`) and output (`stdout`) using `dup2()`.\n\n### Process Management\n\nCore system calls like `fork()` and `execvp()` are utilized for process creation and execution, ensuring concurrent process handling and efficient resource usage.\n\n---\n\n## Getting Started\n\n### Prerequisites\n\n- **Operating System**: Unix/Linux  \n- **Compiler**: GCC or any compatible C compiler  \n\n### Installation\n\n1. Clone the repository:\n\n    git clone git@github.com:SrujayReddy/Custom-Unix-Shell.git\n    cd Custom-Unix-Shell\n\n2. Compile the code:\n\n    gcc wsh.c -o wsh\n\n3. Run the shell:\n\n    ./wsh\n\n---\n\n## Usage\n\n### Basic Commands\n\nRun standard Unix/Linux commands:\n\n    ls -l\n    pwd\n\n### Piping\n\nRedirect the output of one command as input to another:\n\n    ls | grep \".c\"\n\n### Input/Output Redirection\n\nRedirect input and output to/from files:\n\n    cat \u003c input.txt \u003e output.txt\n\n### Command History\n\nAccess previously executed commands:\n\n    history\n\n### Batch Scripting\n\nWrite commands in a `.wsh` script file:\n\n    echo \"Hello, World!\"\n    mkdir new_project\n    cd new_project\n\nRun the script:\n\n    ./wsh script.wsh\n\n---\n\n## Challenges \u0026 Learning\n\nThis project helped me:\n- Master **system-level programming** concepts like process creation, signals, and inter-process communication.\n- Implement complex functionalities such as **piping** and **I/O redirection** efficiently.\n- Debug and optimize **resource management** and edge-case handling in a concurrent environment.\n\n---\n\n## Future Enhancements\n\n- Add support for job control features (`fg`, `bg`, `jobs`).\n- Enhance scripting with loops and conditionals.\n- Introduce customizable shell prompts and aliasing.\n\n---\n\n## License\n\nThis project was developed as part of the **CS 537: Introduction to Operating Systems** course at the University of Wisconsin–Madison. It is shared strictly for educational and learning purposes only.\n\n**Important Notes:**\n- Redistribution or reuse of this code for academic submissions is prohibited and may violate academic integrity policies.\n- The project is licensed under the [MIT License](https://opensource.org/licenses/MIT). Any usage outside academic purposes must include proper attribution.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrujayreddy%2Fcustom-unix-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrujayreddy%2Fcustom-unix-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrujayreddy%2Fcustom-unix-shell/lists"}