{"id":32558819,"url":"https://github.com/msabr/minishell_1337","last_synced_at":"2026-05-07T15:31:40.277Z","repository":{"id":319333095,"uuid":"1001996364","full_name":"msabr/MINISHELL_1337","owner":"msabr","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-08T20:36:54.000Z","size":24618,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-08T22:17:22.021Z","etag":null,"topics":["1337cursus","1337school","42cursus","bash","builtin","command-line","environment","environment-variables","error-handling","execution","file-descriptor","minishell","minishell-42","minishell-guide","minishell42","parsing","path-planning","pathfinding","pipeline","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/msabr.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-14T13:45:13.000Z","updated_at":"2025-11-08T20:36:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/msabr/MINISHELL_1337","commit_stats":null,"previous_names":["msabr/minishell_1337"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/msabr/MINISHELL_1337","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msabr%2FMINISHELL_1337","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msabr%2FMINISHELL_1337/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msabr%2FMINISHELL_1337/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msabr%2FMINISHELL_1337/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msabr","download_url":"https://codeload.github.com/msabr/MINISHELL_1337/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msabr%2FMINISHELL_1337/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32743916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["1337cursus","1337school","42cursus","bash","builtin","command-line","environment","environment-variables","error-handling","execution","file-descriptor","minishell","minishell-42","minishell-guide","minishell42","parsing","path-planning","pathfinding","pipeline","shell"],"created_at":"2025-10-28T23:58:40.263Z","updated_at":"2026-05-07T15:31:40.242Z","avatar_url":"https://github.com/msabr.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minishell - 42 Network\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"minishell.png\" with=\"600\"/\u003e\n\u003c/div\u003e\n\nA minimal shell implementation in C that recreates basic bash functionality as part of the 42 School curriculum.\n\n\n\n## 📋 Table of Contents\n\n- [Overview](#overview)\n- [Features](#features)\n- [Prerequisites](#prerequisites)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Project Structure](#project-structure)\n- [Implementation Details](#implementation-details)\n- [Built-in Commands](#built-in-commands)\n- [Testing](#testing)\n- [Known Issues](#known-issues)\n- [Authors](#authors)\n\n## 🎯 Overview\n\nMinishell is a simplified shell implementation that provides a command-line interface similar to bash. This project demonstrates understanding of:\n\n- Process management and system calls\n- Lexical analysis and parsing\n- Signal handling\n- File descriptor manipulation\n- Memory management\n- Inter-process communication\n\n## ✨ Features\n\n### Core Functionality\n- **Interactive command prompt** with custom banner\n- **Command execution** with PATH resolution\n- **Pipe support** for command chaining (`|`)\n- **Redirections**: \n  - Input redirection (`\u003c`)\n  - Output redirection (`\u003e`)\n  - Append redirection (`\u003e\u003e`)\n  - Here-documents (`\u003c\u003c`)\n- **Variable expansion** (`$VAR`, `$?`)\n- **Quote handling** (single and double quotes)\n- **Signal handling** (Ctrl+C, Ctrl+\\, Ctrl+D)\n\n### Built-in Commands\n- `echo` (with `-n` flag)\n- `cd` (with relative/absolute paths)\n- `pwd`\n- `export`\n- `unset`\n- `env`\n- `exit`\n\n### Advanced Features\n- **Environment variable management**\n- **Exit status tracking** (`$?`)\n- **Syntax error detection**\n- **Memory leak prevention**\n- **History support** (via readline)\n\n## 🔧 Prerequisites\n\n- **GCC** or compatible C compiler\n- **GNU Readline library**\n- **Make**\n- **macOS** (for brew-based readline installation)\n\n## 🚀 Installation\n\n1. **Clone the repository:**\n   ```bash\n   git clone git@github.com:msabr/minishell.git\n   cd minishell\n   ```\n\n2. **Install readline (if not already installed):**\n   ```bash\n   make install-readline\n   ```\n\n3. **Compile the project:**\n   ```bash\n   make\n   ```\n\n4. **Run minishell:**\n   ```bash\n   make run\n   # or\n   ./minishell\n   ```\n\n## 💻 Usage\n\n### Basic Commands\n```bash\nminishell$ echo \"Hello, World!\"\nHello, World!\n\nminishell$ pwd\n/path/to/current/directory\n\nminishell$ ls -la | grep .c\n# Lists all .c files in current directory\n```\n\n### Redirections\n```bash\nminishell$ echo \"content\" \u003e file.txt\nminishell$ cat \u003c file.txt\ncontent\n\nminishell$ echo \"more content\" \u003e\u003e file.txt\nminishell$ cat file.txt\ncontent\nmore content\n```\n\n### Here-documents\n```bash\nminishell$ cat \u003c\u003c EOF\n\u003e line 1\n\u003e line 2\n\u003e EOF\nline 1\nline 2\n```\n\n### Variable Operations\n```bash\nminishell$ export MY_VAR=\"hello\"\nminishell$ echo $MY_VAR\nhello\n\nminishell$ echo $?\n0\n```\n\n## 📁 Project Structure\n\n```\nminishell/\n├── Libft\n│   ├── Makefile\n│   ├── ft_atoi.c\n│   ├── ft_bzero.c\n│   ├── ft_calloc.c\n│   ├── ft_free.c\n│   ├── ft_is_number.c\n│   ├── ft_isalnum.c\n│   ├── ft_isalpha.c\n│   ├── ft_isascii.c\n│   ├── ft_isdigit.c\n│   ├── ft_isprint.c\n│   ├── ft_isspace.c\n│   ├── ft_itoa.c\n│   ├── ft_malloc.c\n│   ├── ft_memchr.c\n│   ├── ft_memcmp.c\n│   ├── ft_memcpy.c\n│   ├── ft_memmove.c\n│   ├── ft_memset.c\n│   ├── ft_putchar_fd.c\n│   ├── ft_putendl_fd.c\n│   ├── ft_putnbr_fd.c\n│   ├── ft_putstr_fd.c\n│   ├── ft_split.c\n│   ├── ft_split_space.c\n│   ├── ft_strcat.c\n│   ├── ft_strchr.c\n│   ├── ft_strcmp.c\n│   ├── ft_strcpy.c\n│   ├── ft_strdup.c\n│   ├── ft_striteri.c\n│   ├── ft_strjoin.c\n│   ├── ft_strlcat.c\n│   ├── ft_strlcpy.c\n│   ├── ft_strlen.c\n│   ├── ft_strmapi.c\n│   ├── ft_strncmp.c\n│   ├── ft_strndup.c\n│   ├── ft_strnstr.c\n│   ├── ft_strrchr.c\n│   ├── ft_strrev.c\n│   ├── ft_strstr.c\n│   ├── ft_strtrim.c\n│   ├── ft_substr.c\n│   ├── ft_tolower.c\n│   ├── ft_toupper.c\n│   └── libft.h\n├── Makefile\n├── execution\n│   ├── banner.c\n│   ├── builtins\n│   │   ├── builtins.c\n│   │   ├── builtins.h\n│   │   ├── cd.c\n│   │   ├── echo.c\n│   │   ├── env.c\n│   │   ├── exit.c\n│   │   ├── export.c\n│   │   ├── export_files.c\n│   │   ├── pwd.c\n│   │   └── unset.c\n│   ├── environment\n│   │   ├── file1.c\n│   │   ├── file2.c\n│   │   └── file3.c\n│   ├── execution.h\n│   ├── exit_status.c\n│   ├── file_descriptor.c\n│   ├── main_loop.c\n│   ├── path_functions.c\n│   ├── path_functions_1.c\n│   ├── pipe\n│   │   ├── handel_pipe1.c\n│   │   ├── handel_pipe2.c\n│   │   ├── handel_pipe3.c\n│   │   ├── handel_pipe4.c\n│   │   └── pipe.h\n│   ├── print_errors.c\n│   ├── redirection\n│   │   ├── redirect_append.c\n│   │   ├── redirect_heredoc.c\n│   │   ├── redirect_heredoc_1.c\n│   │   ├── redirect_overwrite.c\n│   │   ├── redirect_stdin.c\n│   │   ├── redirection.h\n│   │   └── redirection_files.c\n│   ├── signals.c\n│   └── simple_cmd.c\n├── main.c\n├── minishell.h\n└── parsing\n    ├── check_syntax\n    │   ├── syntax_error.c\n    │   └── syntax_tool.c\n    ├── expension2\n    │   ├── expend_helper.c\n    │   ├── expend_helper2.c\n    │   ├── expend_helper3.c\n    │   ├── expend_helper4.c\n    │   ├── expend_herdoc.c\n    │   ├── expend_utils.c\n    │   ├── expend_utils2.c\n    │   ├── expend_utils3.c\n    │   ├── expend_utils4.c\n    │   ├── expend_utils5.c\n    │   └── expension.c\n    ├── lexing\n    │   ├── lexer.c\n    │   ├── lexer_handler2.c\n    │   ├── lexer_handlers.c\n    │   ├── lexer_utils.c\n    │   └── token_utils.c\n    ├── parse_cmd\n    │   ├── export_parse.c\n    │   ├── parse_utils.c\n    │   ├── parse_utils2.c\n    │   ├── parse_utils3.c\n    │   ├── parser.c\n    │   └── parser_helper.c\n    ├── parse_input.c\n    └── parsing.h\n\n12 directories, 111 files\n```\n\n## 🔍 Implementation Details\n\n### Parsing Pipeline\n1. **Lexical Analysis**: Tokenizes input into meaningful units\n2. **Expansion**: Handles variable substitution and quote removal\n3. **Syntax Checking**: Validates command structure\n4. **Command Building**: Constructs executable command structures\n\n### Key Data Structures\n\n```c\ntypedef struct s_cmd {\n    char         **args;     // Command arguments\n    t_redir      *redirs;    // Redirections list\n    bool         in_pipe;    // Pipe context flag\n    struct s_cmd *next;      // Next command in pipeline\n} t_cmd;\n\ntypedef struct s_env {\n    char         *key;              // Variable name\n    char         *value;            // Variable value\n    bool         export_variable;   // Export flag\n    struct s_env *next;             // Next environment variable\n} t_env;\n```\n\n### Memory Management\n- Custom memory allocation tracking via `ft_malloc`/`ft_free`\n- Automatic cleanup on exit\n- Prevention of memory leaks through proper deallocation\n\n## 🔨 Built-in Commands\n\n| Command | Description | Usage |\n|---------|-------------|-------|\n| `echo` | Display text | `echo [-n] [text...]` |\n| `cd` | Change directory | `cd [path]` |\n| `pwd` | Print working directory | `pwd` |\n| `export` | Set environment variables | `export [VAR=value]` |\n| `unset` | Remove environment variables | `unset [VAR]` |\n| `env` | Display environment | `env` |\n| `exit` | Exit the shell | `exit [status]` |\n\n## 🧪 Testing\n\n### Basic Testing\n```bash\n# Test basic commands\nminishell$ echo hello world\nminishell$ pwd\nminishell$ cd /tmp\nminishell$ pwd\n\n# Test pipes\nminishell$ echo \"test\" | cat | cat\n\n# Test redirections\nminishell$ echo \"test\" \u003e file \u0026\u0026 cat file\n\n# Test variables\nminishell$ export TEST=value\nminishell$ echo $TEST\n```\n\n### Error Handling\n```bash\n# Test syntax errors\nminishell$ echo |\nminishell$ cat \u003c\n\n# Test command not found\nminishell$ nonexistent_command\n\n# Test directory execution\nminishell$ ./directory_name\n```\n\n## 🏗️ Build Options\n\n- **Debug mode**: Uncomment `-g3 -fsanitize=address,undefined` in Makefile\n- **Clean build**: `make fclean \u0026\u0026 make`\n- **Rebuild**: `make re`\n\n## ⚠️ Known Issues\n\n- Limited error handling for edge cases\n- Some advanced bash features not implemented\n- Platform-specific (macOS-oriented due to brew readline)\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## 📄 License\n\nThis project is part of the 42 School curriculum. Please respect academic integrity guidelines.\n\n## 👥 Authors\n\n- **msabr** - Main developer\n- **kabouelf** - Contributor\n  \n```\n\t███╗   ███╗██╗███╗   ██╗██╗ ██████╗██╗   ╔██╗╔████████╗██╗\n\t██╔████╔██║██║██╔██╗ ██║██║██╔════╝██╝   ╚██╝║██══════╝██║\n\t██║╚██╔╝██║██║██║╚██╗██║██║╚█████╗ █████████╗║████████╗██║\n\t██║ ╚═╝ ██║██║██║  ╚███║██║ ╚═══██╗██╔═══╗██║║██╔═════╝██║\n\t██║     ██║██║██║   ╚██╝██║██████╔╝██║   ║██║║████████╗████████╗\n\t╚═╝     ╚═╝╚═╝╚═╝    ╚═╝═╝╚══════╝ ╚═╝   ╚══╝╚═══════╝╚═══════╝\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsabr%2Fminishell_1337","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsabr%2Fminishell_1337","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsabr%2Fminishell_1337/lists"}