{"id":13903201,"url":"https://github.com/moshell-lang/moshell","last_synced_at":"2025-07-18T00:33:42.001Z","repository":{"id":72034264,"uuid":"596702151","full_name":"moshell-lang/moshell","owner":"moshell-lang","description":"A typed shell script language, with modern syntax implemented in Rust™","archived":false,"fork":false,"pushed_at":"2024-08-25T17:05:55.000Z","size":3389,"stargazers_count":21,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-25T18:25:47.473Z","etag":null,"topics":["compiler","hacktoberfest","interpreter","language","scripting-language","shell","typing"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moshell-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2023-02-02T18:52:43.000Z","updated_at":"2024-08-25T18:26:09.302Z","dependencies_parsed_at":"2024-08-25T18:25:54.209Z","dependency_job_id":"25e379d0-944b-4e1c-babe-25fda148cb91","html_url":"https://github.com/moshell-lang/moshell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moshell-lang%2Fmoshell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moshell-lang%2Fmoshell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moshell-lang%2Fmoshell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moshell-lang%2Fmoshell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moshell-lang","download_url":"https://codeload.github.com/moshell-lang/moshell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226320953,"owners_count":17606380,"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":["compiler","hacktoberfest","interpreter","language","scripting-language","shell","typing"],"created_at":"2024-08-06T22:01:51.609Z","updated_at":"2024-11-25T11:31:26.369Z","avatar_url":"https://github.com/moshell-lang.png","language":"Rust","funding_links":[],"categories":["shell"],"sub_categories":[],"readme":"# Moshell\n\nTry it on [moshell.dev](https://moshell.dev) !\n\nMoshell is a modern shell scripting language with a static type system.\nThis repository hosts the source code from the parser to the interpreter and its standard library.\n\n## Motivation\n\nThe shell is a powerful tool, but it's also a very old one.\nWhile having a permissive language can be a good thing, it makes it harder to statically analyze a shell script for errors.\n\nDue to the highly interpreted nature of the Shell, escaping and quoting arguments can be a pain to get right.\nMoshell resolves arguments before evaluating them, so references to variables do not need to be escaped.\n\nArithmetic evaluation traditionally needs to be made explicit to be differentiated from a command, where Moshell allows direct arithmetic evaluation if not at the beginning at a statement.\n\nMoshell also comes with different data types, such as `Int`, `Float`, `Bool` or `String`. This allows for clearer and more elegant code and avoids arithmetic between incompatible types.\n\n## Installation\n\nMoshell is available from different sources:\n\n- You can download a prebuilt nightly binary with `curl -L moshell.dev/setup.sh | sh`.\n- If you have a Rust toolchain, CMake and a C++20 compiler installed, you can build a [development version](#build-and-run).\n- Docker users can run a prebuilt image with `docker run -it ghcr.io/moshell-lang/moshell:master`.\n\n## Build and Run\n\nYou need a stable Rust compiler to build Moshell frontend on a GNU/Linux system.\nThe MSRV is the latest stable version of Rust.\n\nThe VM needs a C++20 compiler and a CMake 3.15+ installation. Its build script will automatically be called by Cargo.\nGCC starting from version 10 and Clang starting from version 11 are supported.\n\n```sh\ncargo run # Run the interactive prompt\ncargo run -- \u003cfile\u003e # Run a file\n```\n\nYou can also build a release binary:\n```sh\ncargo build --release\n./target/release/moshell # Run the interactive prompt\n./target/release/moshell \u003cfile\u003e # Run a file\n```\n\nYou can export the `MOSHELL_STD` environment variable to specify a path to the standard library.\n\n```sh\nexport MOSHELL_STD=/path/to/moshell/lib\n```\n\n## Examples\n\nHere's some Bash vs Moshell comparisons.\n\nNote that Moshell examples cannot currently be run as is.\n\n### Iterating over arguments\n\n#### Bash\n\n```bash\nuser=''\nport=0\nwhile [[ $# -ne 0 ]]; do\n   case \"$1\" in\n        -u|--user)\n             user=\"$2\"\n             shift\n             ;;\n        -port|--port)\n             if [[ \"$2\" =~ ^[0-9]+$ ]]; then\n                 port=\"$2\"\n             else\n                 echo \"Invalid port\" \u003e\u00262\n                 exit 1\n             fi\n             shift\n             ;;\n        *)\n             echo \"Unknown argument $1\" \u003e\u00262\n             exit 1\n             ;;\n   esac\n   shift\ndone\n\nif [ -z \"$user\" ] || [ \"$port\" -eq 0 ]; then\n    echo \"No user or port specified\" \u003e\u00262\n    exit 1\nfi\n```\n\n### Moshell\n\nMoshell functions can return values rather than an exitcode. This allows the `shift` operation to be redefined to return the shifted argument then shift arguments to the left.\n\nAs everything is text in a shell, values of a certain type can be _parsed_ as another type using methods on `String`.\n\nThe `$(expr)` syntax substitutes the stdout of the underlying expression and the `{expr}` will substitute the return value of the expression.  \nAnother point is that substitution is automatically protected, thus a `$x` and `$(...)` expression is equivalent to bash `\"$1\"` and `\"$(...)\"` syntax.\n\n```scala\nvar user = ''\nvar port = 0\nwhile [ $# ] match {shift} { // calls the shift function and substitutes its return value\n     -u | --user    =\u003e user = shift()\n     -port | --port =\u003e port = shift().parse_int().expect(\"Invalid port\")\n     $arg           =\u003e panic \"Unknown argument $arg\"\n}\n\nif $user.is_empty() || $port == 0 {\n    panic('No user specified')\n}\n```\n\n\n## Current state\n\nMoshell is a project in its early stages.\n\n- [x] Lexer + Parser\n  - [x] Standard shell expressions\n  - [x] Control flow\n  - [x] Type hints\n  - [x] Array indexing and ranges\n  - [x] User defined structures\n  - [ ] User defined enums\n- [x] Static analysis\n  - [x] Symbol resolution\n  - [x] Imports resolution\n  - [x] Qualified names\n  - [x] Primitive type checking\n  - [x] Built-in primitive type operations\n  - [ ] Detailed error reports *(in progress)*\n  - [x] Reefs (library support)\n  - [x] Generic types\n  - [ ] Standard types (`Option[T]`, `Result[A, E]`, `Iterable[T]`...)\n  - [ ] User defined structures *(in progress)*\n- [x] Bytecode compiler and interpreter\n  - [x] Spawn processes and use typed variables\n  - [x] Control flow\n  - [x] Function calls\n  - [x] Panic\n  - [x] Dynamic memory handling (Garbage Collector)\n  - [X] Vectors *(partial)*\n  - [ ] Closures\n- [x] REPL\n  - [x] Visualize AST and IR\n  - [x] Visualize Bytecode\n  - [ ] Display diagnostics *(partial)*\n  - [x] Symbol reuse\n  - [ ] Shell-like prompt *(partial)*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoshell-lang%2Fmoshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoshell-lang%2Fmoshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoshell-lang%2Fmoshell/lists"}