{"id":13672516,"url":"https://github.com/rust-shell-script/rust-shell-script","last_synced_at":"2025-04-13T10:20:37.787Z","repository":{"id":98949327,"uuid":"207004259","full_name":"rust-shell-script/rust-shell-script","owner":"rust-shell-script","description":"Rustlike shell scripting language; Resilient \u0026 robust shell script, compiling to rust code/bash script","archived":false,"fork":false,"pushed_at":"2021-10-22T05:07:21.000Z","size":31,"stargazers_count":59,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T01:46:36.686Z","etag":null,"topics":["command-line","rust","shell-script"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/rust-shell-script.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}},"created_at":"2019-09-07T17:41:50.000Z","updated_at":"2024-12-25T20:32:07.000Z","dependencies_parsed_at":"2023-04-24T05:08:29.798Z","dependency_job_id":null,"html_url":"https://github.com/rust-shell-script/rust-shell-script","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/rust-shell-script%2Frust-shell-script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-shell-script%2Frust-shell-script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-shell-script%2Frust-shell-script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rust-shell-script%2Frust-shell-script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rust-shell-script","download_url":"https://codeload.github.com/rust-shell-script/rust-shell-script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248696133,"owners_count":21147075,"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":["command-line","rust","shell-script"],"created_at":"2024-08-02T09:01:37.945Z","updated_at":"2025-04-13T10:20:37.764Z","avatar_url":"https://github.com/rust-shell-script.png","language":"Rust","readme":"# rust-shell-script\n~~Rustlike shell scripting language (WIP)~~  -\u003e use [rust_cmd_lib](https://github.com/rust-shell-script/rust_cmd_lib) instead.\n\nResilient \u0026 robust shell script, compiling to rust code/bash script\n\n# Build \u0026 Install\n```bash\n$ cargo build\n```\n\n# Example\n\n## Source file\n\n```bash\nrust-shell-script$:~/rust-shell-script$ cat examples/hello.rss\ncmd error_command() {\n    do_something_failed\n}\n\nfun bad_greeting(name) {\n    info \"Running error_command ...\"\n    error_command\n    output \"hello, ${name}!\"\n}\n\nfun good_greeting(name) {\n    info \"Running good_command ...\"\n    output \"hello, ${name}!\"\n}\n\ncmd main() {\n    let bad_ans = $(bad_greeting \"rust-shell-script\")\n    info \"${bad_ans}\"\n    let good_ans = $(good_greeting \"rust-shell-script\")\n    info \"${good_ans}\"\n    return 0\n}\n```\n\n## Compiling to bash\n\n### compiling\n```bash\nrust-shell-script:~/rust-shell-script$ target/debug/rust-shell-script -t bash examples/hello.rss \nGenerating bash script to examples/hello.sh ...\n```\n\n### passing shellcheck\n```bash\nrust-shell-script:~/rust-shell-script$ shellcheck examples/hello.sh \nrust-shell-script:~/rust-shell-script$ echo $?\n0\n```\n\n### generated bash script\n```bash\n#!/bin/bash\n#\n# Generated by rust-shell-script\n#\n. \"${RUNTIME:-.}/cmd_lib.sh\"\n\nerror_command() {\n    do_something_failed\n}\n\nfunction bad_greeting() {\n    local name=\"$1\"\n\n    info \"Running error_command ...\"\n    error_command\n    output \"hello, ${name}!\"\n}\n\nfunction good_greeting() {\n    local name=\"$1\"\n\n    info \"Running good_command ...\"\n    output \"hello, ${name}!\"\n}\n\nmain() {\n    local bad_ans\n    bad_ans=$(_call bad_greeting \"rust-shell-script\")\n    info \"${bad_ans}\"\n    local good_ans\n    good_ans=$(_call good_greeting \"rust-shell-script\")\n    info \"${good_ans}\"\n    return 0\n}\n\nmain \"$@\"\n```\n\n### running script\n\nAll command errors will be captured automatically, even within bash function:\n```bash\nrust-shell-script:~/rust-shell-script/examples$ ./hello.sh \nRunning error_command ...\n/bin/bash: line 219: do_something_failed: command not found\nFATAL: Running command (bad_ans=$(_call bad_greeting \"rust-shell-script\")) near script hello.sh:main():1 failed (ret=127)\n```\n\n## Compiling to rust\n\n### compiling\n```bash\ntao@sophia:~/rust-shell-script$ target/debug/rust-shell-script -t rust examples/hello.rss \nGenerating rust code to examples/hello.rs ...\n```\n\n### generated rust code\n```rust\n// Generated by rust-shell-script\nmod cmd_lib;\nuse crate::cmd_lib::{CmdResult, FunResult};\n\nfn error_command() -\u003e CmdResult {\n    run_cmd!(\"do_something_failed\")\n}\n\nfn bad_greeting(name: \u0026str) -\u003e FunResult {\n    info!(\"Running error_command ...\");\n    error_command()?;\n    output!(\"hello, {}!\", name)\n}\n\nfn good_greeting(name: \u0026str) -\u003e FunResult {\n    info!(\"Running good_command ...\");\n    output!(\"hello, {}!\", name)\n}\n\nfn main() -\u003e CmdResult {\n    let bad_ans = bad_greeting(\"rust-shell-script\")?;;\n    info!(\"{}\", bad_ans);\n    let good_ans = good_greeting(\"rust-shell-script\")?;;\n    info!(\"{}\", good_ans);\n    return Ok(())\n}\n```\n\n### running rust code\n```bash\nrust-shell-script:~/rust-shell-script/examples$ rustc hello.rs\nrust-shell-script:~/rust-shell-script/examples$ ./hello\nRunning error_command ...\nRunning [\"do_something_failed\"] ...\nError: Os { code: 2, kind: NotFound, message: \"No such file or directory\" }\n```\n","funding_links":[],"categories":["Rust","rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-shell-script%2Frust-shell-script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frust-shell-script%2Frust-shell-script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frust-shell-script%2Frust-shell-script/lists"}