{"id":19468849,"url":"https://github.com/ndevu12/simple_shell","last_synced_at":"2026-05-15T11:02:32.653Z","repository":{"id":206704554,"uuid":"717515913","full_name":"Ndevu12/simple_shell","owner":"Ndevu12","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-18T07:43:37.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-08T04:51:40.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Ndevu12.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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-11T17:44:30.000Z","updated_at":"2023-11-12T17:38:51.000Z","dependencies_parsed_at":"2024-11-10T18:44:26.516Z","dependency_job_id":"73bbf9fb-79c3-446a-a2d0-797e2b568304","html_url":"https://github.com/Ndevu12/simple_shell","commit_stats":null,"previous_names":["ndevu12/simple_shell"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ndevu12%2Fsimple_shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ndevu12%2Fsimple_shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ndevu12%2Fsimple_shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ndevu12%2Fsimple_shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ndevu12","download_url":"https://codeload.github.com/Ndevu12/simple_shell/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240682985,"owners_count":19840610,"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":[],"created_at":"2024-11-10T18:44:21.236Z","updated_at":"2026-05-15T11:02:32.646Z","avatar_url":"https://github.com/Ndevu12.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Shell\r\n\r\nA custom Unix shell implementation written in C as part of the ALX Software Engineering Program.\r\n\r\n## Table of Contents\r\n\r\n- [Overview](#overview)\r\n- [Features](#features)\r\n- [Project Structure](#project-structure)\r\n- [System Requirements](#system-requirements)\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n- [Built-in Commands](#built-in-commands)\r\n- [Authors](#authors)\r\n\r\n## Overview\r\n\r\nThis Simple Shell project is a UNIX command line interpreter that replicates basic functionalities of the standard shell (sh). It provides an interface for users to interact with the operating system by executing commands. This project was developed as a milestone project for the ALX Software Engineering Program.\r\n\r\n## Features\r\n\r\nOur shell implementation supports the following features:\r\n\r\n1. **Interactive Mode**: Displays a prompt (`hsh$`) and waits for user commands\r\n2. **Non-interactive Mode**: Processes commands from standard input without displaying a prompt\r\n3. **Command Execution**: Executes commands with arguments\r\n4. **PATH Handling**: Searches for executables in the directories listed in the PATH environment variable\r\n5. **Built-in Commands**: Supports built-in commands like `exit` and `env`\r\n6. **Error Handling**: Provides appropriate error messages when commands aren't found\r\n7. **EOF Handling**: Properly handles end-of-file condition (Ctrl+D)\r\n8. **Memory Management**: Carefully manages memory allocation and deallocation\r\n\r\n## Project Structure\r\n\r\nThe project is organized into several C files, each handling specific functionality:\r\n\r\n- **main.c**: The entry point of the shell program\r\n- **main.h**: Header file containing all function prototypes and necessary libraries\r\n- **str_function.c**: Contains string manipulation functions\r\n- **searchPath.c**: Handles PATH environment variable processing\r\n- **env.c**: Functions for environment variable management\r\n- **ex.c**: Functions for command execution\r\n- **mem.c**: Memory management functions\r\n- **checkEmptyFile.c**: Verifies if input is empty\r\n\r\n## Implementation Details\r\n\r\nThe shell implements the following functionality as specified in the project requirements:\r\n\r\n1. Simple command execution with a prompt\r\n2. Command execution history retention\r\n3. Basic command parsing without advanced features like pipes or redirections\r\n4. Command search in PATH directories\r\n5. Error handling for command not found\r\n6. EOF (Ctrl+D) condition handling\r\n7. Command line argument handling\r\n8. Proper PATH handling without unnecessary fork calls\r\n9. Built-in `exit` command implementation\r\n10. Built-in `env` command for environment variable display\r\n11. Custom implementations of standard library functions\r\n\r\n## System Requirements\r\n\r\n### Platform Compatibility\r\n\r\nThis shell is **strictly designed for Unix/Linux environments** and is not compatible with native Windows systems due to its dependency on Unix-specific system calls and headers. The shell relies on:\r\n\r\n- **Unix System Calls**: fork(), exec(), wait(), etc.\r\n- **Unix File System**: Path conventions and file operations\r\n- **Unix Process Model**: Parent-child process relationships\r\n\r\n### Dependencies\r\n\r\nThe shell requires:\r\n\r\n- **Operating System**: Linux/Unix environment (Ubuntu 20.04 LTS recommended)\r\n- **Compiler**: GCC with C89 standard support\r\n- **Required Headers**: Standard C libraries and Unix-specific headers:\r\n  - `\u003csys/wait.h\u003e`: For process control and wait functions\r\n  - `\u003csys/stat.h\u003e`: For file status and information\r\n  - `\u003csys/types.h\u003e`: For system data types\r\n  - `\u003cunistd.h\u003e`: For Unix standard functions like fork, exec\r\n\r\n### Windows Users\r\n\r\nIf you're using Windows, you'll need a Unix-compatible environment to compile and run this shell:\r\n\r\n1. **Windows Subsystem for Linux (WSL)** - Recommended approach:\r\n\r\n   ```powershell\r\n   # Install WSL with Ubuntu\r\n   wsl --install -d Ubuntu\r\n   \r\n   # After installation and restart, access your project through:\r\n   wsl\r\n   cd /mnt/c/Users/Ndevu/Desktop/recap_on_C/real_projects/simple_shell\r\n   ```\r\n\r\n2. **Alternative options**:\r\n   - **Cygwin**: Provides Unix-like environment and tools on Windows\r\n   - **MinGW/MSYS2**: Minimalist GNU for Windows with Unix tools\r\n   - **VirtualBox/VMware**: Run a complete Linux virtual machine\r\n\r\n## Installation\r\n\r\nTo compile and run this shell:\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/Ndevu12/simple_shell.git\r\n\r\n# Navigate to the project directory\r\ncd simple_shell\r\n\r\n# Compile the program\r\ngcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c -o shell\r\n\r\n# Run the shell\r\n./shell\r\n```\r\n\r\n### Compilation Notes\r\n\r\nWhen compiling on Windows without a proper Unix environment, you may encounter errors like:\r\n\r\n```\r\nfatal error: sys/wait.h: No such file or directory\r\n#include \u003csys/wait.h\u003e\r\n```\r\n\r\nThis is expected as these are Unix-specific headers. Please use one of the Unix-compatible environments mentioned in the System Requirements section.\r\n\r\n## Usage\r\n\r\nAfter running the shell, you'll see a prompt where you can enter commands:\r\n\r\n```bash\r\nhsh$ ls\r\n[files and directories will be listed here]\r\nhsh$ pwd\r\n/current/working/directory\r\nhsh$ /bin/ls\r\n[files and directories will be listed here]\r\nhsh$ exit\r\n```\r\n\r\n## Built-in Commands\r\n\r\nThe shell supports the following built-in commands:\r\n\r\n- **exit**: Exits the shell (optionally with a status code)\r\n- **env**: Displays the current environment variables\r\n\r\n## Authors\r\n\r\nThis project was created by:\r\n\r\n- NIYOKWIZERWA Jean Paul Elisa (Ndevu12) - [Email](mailto:niyokwizerwajeanpaulelisa@gmail.com)\r\n- Jackline NYANGANJOKI - [Email](mailto:jacklinenyaganjoki@gmail.com)\r\n\r\nCreated as part of the ALX Software Engineering Program.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndevu12%2Fsimple_shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fndevu12%2Fsimple_shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fndevu12%2Fsimple_shell/lists"}