{"id":15047728,"url":"https://github.com/konvt/simsh","last_synced_at":"2025-03-13T21:42:10.351Z","repository":{"id":245416549,"uuid":"818126273","full_name":"Konvt/simsh","owner":"Konvt","description":"A simple Linux Shell written in Modern C++.","archived":false,"fork":false,"pushed_at":"2024-11-26T16:56:02.000Z","size":205,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T17:17:19.079Z","etag":null,"topics":["cmake","cpp","cpp20","linux","linux-shell","makefile","modern-cpp","shell","xmake"],"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/Konvt.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":"2024-06-21T06:47:28.000Z","updated_at":"2024-11-26T16:56:05.000Z","dependencies_parsed_at":"2024-07-17T10:27:42.193Z","dependency_job_id":"32e1d9f6-e1a8-4f3a-b109-facfdf087532","html_url":"https://github.com/Konvt/simsh","commit_stats":null,"previous_names":["konvt/simsh"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fsimsh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fsimsh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fsimsh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Konvt%2Fsimsh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Konvt","download_url":"https://codeload.github.com/Konvt/simsh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243489778,"owners_count":20298997,"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":["cmake","cpp","cpp20","linux","linux-shell","makefile","modern-cpp","shell","xmake"],"created_at":"2024-09-24T21:03:38.947Z","updated_at":"2025-03-13T21:42:10.321Z","avatar_url":"https://github.com/Konvt.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simsh - The simple implementation of shell\n\n**Contents**\n- [simsh - The simple implementation of shell](#simsh---the-simple-implementation-of-shell)\n  - [Features](#features)\n  - [How to build](#how-to-build)\n    - [xmake (recommended)](#xmake-recommended)\n    - [Makefile](#makefile)\n    - [CMake](#cmake)\n    - [Binary](#binary)\n  - [How to use](#how-to-use)\n- [simsh - Shell 的简单实现 - zh\\_cn](#simsh---shell-的简单实现---zh_cn)\n  - [特点](#特点)\n  - [如何构建](#如何构建)\n    - [xmake（推荐）](#xmake推荐)\n    - [Makefile](#makefile-1)\n    - [CMake](#cmake-1)\n    - [Binary](#binary-1)\n  - [如何使用](#如何使用)\n\nA simple Linux Shell written in Modern C++.\n\n## Features\n- Supports nested statements\n- Supports most redirection functionalities, including pipes\n- Syntax parsing based on recursive descent method\n- Modular design\n- Adheres to Modern C++ standards\n\n## How to build\nThe syntax standard used is C++20 (with `ranges` and `format`), so the compiler required for building needs to be at least g++13 or clang14.\n\nThe project provides three build methods, **but it is recommended not to use more than one build tool simultaneously.**\n\nEach method assumes the compilation tool **fully supports** `std::ranges` or `std::format`.\n\nRun the program with `./simsh`.\n\n### xmake (recommended)\n```xmake\nxmake run simsh\n```\n### Makefile\n```makefile\nmake -j4 all\n```\n### CMake\nThe project's `CMakeLists.txt` is generated by `xmake`, and its usability is not guaranteed; if you have `xmake` and prefer using `CMake`, you can use `xmake project -k cmake` to generate `CMakeLists.txt`.\n```cmake\ncmake -S . -B build \u0026\u0026 cmake --build build\n```\n### Binary\nSince some functions rely on `glibc`, the [binary files](https://github.com/Konvt/simsh/releases/tag/v0.1.1) are not guaranteed to run correctly.\n\nFor more details, refer to the build environment declarations in [Releases](https://github.com/Konvt/simsh/releases).\n\n## How to use\nJust like using bash.\n\nYou can pass command line arguments at startup to execute a single statement.\n```sh\n./simsh -c \"whoami \u0026\u0026 pwd\"  # Single statement must include the -c parameter\n./simsh \"whoami\" \"\u0026\u0026\" \"pwd\" # Or split into multiple statements in advance, no -c parameter needed\n```\n\nYou can also read commands from a file.\n```sh\n(echo \"whoami \u0026\u0026 pwd\" \u003e ./script.txt) \u0026\u0026 ./simsh ./script.txt\n# No specific extension required, just needs to be a text format file\n```\n\nAdditionally, `simsh` will expand special symbols (i.e., `$$` and `~`) to the current program's `pid` or the user's home directory path, respectively.\n```sh\n./simsh -c \"echo ~ \u0026\u0026 echo \\$\\$\"\n```\n\nIf run as the `root` user, the default `simsh::CLI` object will change the command prompt to a colorless format ending with `#`.\n\n- - -\n\n# simsh - Shell 的简单实现 - zh_cn\n\n一个由 Modern C++ 编写的、简单的 Linux Shell。\n\n## 特点\n- 支持嵌套语句\n- 支持包括管道在内的大部分重定向功能\n- 基于递归下降法进行语法解析\n- 模块化设计\n- 遵循 Modern C++ 规范\n\n## 如何构建\n使用的语法标准为 C++20（with `ranges` and `format`），故构建时的编译器需要至少是 g++13，或 clang14\n\n项目提供了三种构建方式，**但这里建议不要同时使用两种及以上的构建工具**。\n\n每种方式都假定使用的编译工具**已完全支持** `std::ranges` 或 `std::format`。\n\n使用 `./simsh` 运行程序。\n### xmake（推荐）\n```xmake\nxmake run simsh\n```\n### Makefile\n```makefile\nmake -j4 all\n```\n### CMake\n项目的 `CMakeLists.txt` 是由 `xmake` 生成的，不保证绝对可用；如果你有 `xmake` 且更偏好使用 `CMake`，可以使用 `xmake project -k cmake` 生成 `CMakeLists.txt`。\n```cmake\ncmake -S . -B build \u0026\u0026 cmake --build build\n```\n### Binary\n因为部分函数依赖于 `glibc`，因此不保证[二进制文件](https://github.com/Konvt/simsh/releases/tag/v0.1.1)能够正常运行。\n\n详情可以参照 [Releases](https://github.com/Konvt/simsh/releases) 中的构建环境声明。\n\n## 如何使用\n就像使用 bash 一样。\n\n可以在启动时传入命令行参数，以执行单条语句。\n```sh\n./simsh -c \"whoami \u0026\u0026 pwd\"  # 单条语句必须带有 -c 参数\n./simsh \"whoami\" \"\u0026\u0026\" \"pwd\" # 或者提前分割为多条语句传入，此时不需要 -c 参数\n```\n\n也可以从文件读取命令。\n```sh\n(echo \"whoami \u0026\u0026 pwd\" \u003e ./script.txt) \u0026\u0026 ./simsh ./script.txt\n# 没有后缀要求，只要求文件是文本格式\n```\n\n此外，`simsh` 在遇到特殊标记（即 `$$` 和 `~`）时，会将其展开为当前程序的 `pid` 或用户家目录的绝对路径。\n```sh\n./simsh -c \"echo ~ \u0026\u0026 echo \\$\\$\"\n```\n\n如果以 `root` 用户身份运行，默认的 `simsh::CLI` 对象会将命令提示符替换为没有颜色、且以 `#` 结尾的格式。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonvt%2Fsimsh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkonvt%2Fsimsh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkonvt%2Fsimsh/lists"}