{"id":26063986,"url":"https://github.com/cherry-embedded/cherrysh","last_synced_at":"2026-04-01T23:35:06.671Z","repository":{"id":230190776,"uuid":"767873903","full_name":"cherry-embedded/CherrySH","owner":"cherry-embedded","description":"CherryShell is a tiny and multifunction shell specifically designed for embedded applications","archived":false,"fork":false,"pushed_at":"2025-08-30T11:27:39.000Z","size":308,"stargazers_count":36,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-08-30T13:19:53.104Z","etag":null,"topics":["bash","cmd-parser","readline","shell"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cherry-embedded.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-06T03:39:00.000Z","updated_at":"2025-08-30T11:27:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"bc33a54d-9883-4307-b2bf-c6aecee45060","html_url":"https://github.com/cherry-embedded/CherrySH","commit_stats":null,"previous_names":["cherry-embedded/cherrysh"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/cherry-embedded/CherrySH","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-embedded%2FCherrySH","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-embedded%2FCherrySH/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-embedded%2FCherrySH/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-embedded%2FCherrySH/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cherry-embedded","download_url":"https://codeload.github.com/cherry-embedded/CherrySH/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cherry-embedded%2FCherrySH/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: 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":["bash","cmd-parser","readline","shell"],"created_at":"2025-03-08T17:57:50.340Z","updated_at":"2026-04-01T23:35:06.660Z","avatar_url":"https://github.com/cherry-embedded.png","language":"C","readme":"**English | [简体中文](README_zh.md)**\n\n\u003ch1 align=\"center\" style=\"margin: 30px 0 30px; font-weight: bold;\"\u003eCherrySH\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"https://github.com/cherry-embedded/CherrySH/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/release/cherry-embedded/CherrySH.svg\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/cherry-embedded/CherrySH/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/cherry-embedded/CherrySH.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nCherrySH is a tiny shell specifically designed for embedded applications.\n\n## Features\n\n- Support TAB completion, including command and path completion\n- Support command history, navigable with the `↑` and `↓` arrow keys\n- Support environment variables using the `$` prefix, e.g., `$PATH`\n- Support setting username, hostname, and path/prompt\n- Support non-blocking mode; compatible with bare-metal and RTOS\n- Support cursor left/right movement and `HOME`/`END` cursor positioning\n- Support key combinations, including `Ctrl + \u003ckey\u003e`, `Alt + \u003ckey\u003e`, `F1-F12`, etc.\n- Support signal handling: capture and handle signals such as `Ctrl+C` (`SIGINT`) and `Ctrl+Z` (`SIGTSTP`) to interrupt the currently running shell task\n- Support user login; requires implementing a hash function (default: `strcmp`)\n- Support adding, modifying, deleting, and reading environment variables\n- Support filesystems: FatFS, FileX, LittleFS, RomFS, etc. (TODO)\n- Support an `exit` mechanism to terminate command execution, return context, and call a configured handler; can be implemented with `setjmp` for bare-metal (TODO)\n- Support job control: run commands in foreground or background and manage them with `fg`, `bg`, `jobs` (TODO)\n- Support multi-user command permissions (TODO)\n\n## Demo\n\n![test1](./doc/test1.png)\n\n![test2](./doc/test2.png)\n\n## Porting\n\nTaking the example of the HPMicro hpm5301evklite board.\n\n- Command lookup uses the GCC section, so we need to modify the linkerscript file to add the relevant section, for example in gcc ld:\n\n```\n    .text : {\n    .....\n\n    . = ALIGN(4);\n    __fsymtab_start = .;\n    KEEP(*(FSymTab))\n    __fsymtab_end = .;\n    . = ALIGN(4);\n    __vsymtab_start = .;\n    KEEP(*(VSymTab))\n    __vsymtab_end = .;\n    . = ALIGN(4);\n    }\n\n```\n\n- Implement shell put and get api, and suggest to use rx irq + ringbuf to get chars.\n\n``` c\n#include \"csh.h\"\n\nstatic chry_shell_t csh;\n\nstatic uint16_t csh_sput_cb(chry_readline_t *rl, const void *data, uint16_t size)\n{\n    uint16_t i;\n    (void)rl;\n    for (i = 0; i \u003c size; i++) {\n        if (status_success != uart_send_byte(HPM_UART0, ((uint8_t *)data)[i])) {\n            break;\n        }\n    }\n\n    return i;\n}\n\nstatic uint16_t csh_sget_cb(chry_readline_t *rl, void *data, uint16_t size)\n{\n    uint16_t i;\n    (void)rl;\n    for (i = 0; i \u003c size; i++) {\n        if (status_success != uart_receive_byte(HPM_UART0, (uint8_t *)data + i)) {\n            break;\n        }\n    }\n\n    return i;\n}\n```\n\n- Init shell, refer to samples\n- Call `chry_shell_task_exec` and `chry_shell_task_repl` in task，refer to samples\n- Set system env variables\n\n``` c\n#define __ENV_PATH \"/sbin:/bin\"\nconst char ENV_PATH[] = __ENV_PATH;\nCSH_RVAR_EXPORT(ENV_PATH, PATH, sizeof(__ENV_PATH));\n\n#define __ENV_ZERO \"\"\nconst char ENV_ZERO[] = __ENV_ZERO;\nCSH_RVAR_EXPORT(ENV_ZERO, ZERO, sizeof(__ENV_ZERO));\n```\n\n- Use `CSH_CMD_EXPORT` to export command\n\n``` c\nstatic int write_led(int argc, char **argv)\n{\n    if (argc \u003c 2) {\n        printf(\"usage: write_led \u003cstatus\u003e\\r\\n\\r\\n\");\n        printf(\"  status    0 or 1\\r\\n\\r\\n\");\n        return -1;\n    }\n\n    board_led_write(atoi(argv[1]) == 0);\n    return 0;\n}\nCSH_CMD_EXPORT(write_led, );\n\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherry-embedded%2Fcherrysh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcherry-embedded%2Fcherrysh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcherry-embedded%2Fcherrysh/lists"}