{"id":13587236,"url":"https://github.com/bashbox/bashbox","last_synced_at":"2025-04-07T21:33:16.933Z","repository":{"id":38474815,"uuid":"280165806","full_name":"bashbox/bashbox","owner":"bashbox","description":"A bash compiler written in bash to help create modular and maintainable bash projects.","archived":false,"fork":false,"pushed_at":"2024-07-18T12:11:30.000Z","size":598,"stargazers_count":24,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-06T06:40:37.471Z","etag":null,"topics":["bash","bash-beautification","bash-error-checking","bash-minification","bash-optimizaton","bash-scripting","bash-syntax-checking","beautification","compiler","optimization"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bashbox.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":"2020-07-16T13:48:20.000Z","updated_at":"2024-10-09T12:43:35.000Z","dependencies_parsed_at":"2024-11-06T06:33:06.149Z","dependency_job_id":"007a655c-e64c-4870-aa90-a581035b0cda","html_url":"https://github.com/bashbox/bashbox","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbox%2Fbashbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbox%2Fbashbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbox%2Fbashbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bashbox%2Fbashbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bashbox","download_url":"https://codeload.github.com/bashbox/bashbox/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247732830,"owners_count":20986935,"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":["bash","bash-beautification","bash-error-checking","bash-minification","bash-optimizaton","bash-scripting","bash-syntax-checking","beautification","compiler","optimization"],"created_at":"2024-08-01T15:06:06.959Z","updated_at":"2025-04-07T21:33:11.917Z","avatar_url":"https://github.com/bashbox.png","language":"Shell","readme":"## Introduction\n\nBashbox is a wannabe bash _compiler_ which aims to help create modular and maintainable bash projects.\n\nTo give huge bash codebase a predictable form. Specially for the single script bash projects with thousands of lines of code.\n\nBashbox compiles your modular bash project into a single file along bringing a standard set of bash enforcements to ensure that your code is safe and less error-prone while you code and test before publishing it in an production environment.\n\nAnd hey, we finally have _some sort of_ `std` library for bash too! Along the ability to create your own library and let others use it. We have a cool stack trace thingy too!\n\nBashbox design is `cargo` inspired but _for the bash buddies_, so I hope that tells the rest.\n\n## Getting Started\n\nYou can start developing on Gitpod right away! Just press the button below.\n\n[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/bashbox/bashbox)\n\nOr simply run the following command to install bashbox in your local system:\n```bash\ncurl --proto '=https' --tlsv1.2 -sSfL \"https://git.io/Jc9bH\" | bash -s selfinstall\n```\n\nNow you are all set for creating awesome bash projects with it:\n```bash\nbashbox new project-name\n```\n\n## An example project\n\n\u003e `src/main.sh`\n```bash\nuse foo;\n\nfunction main() {\n\techo \"Hello world\";\n\tfoo \"bar\";\n}\n```\n\n\u003e `src/foo.sh`\n```bash\nfunction foo() {\n\tlocal _input=\"$1\";\n\techo \"Hello my name is ${_input}\";\n}\n```\n\nYou can run the project by:\n\n```bash\nbashbox run --release\n```\n\nIf you want to pass some arguments:\n\n```bash\nbashbox run --release -- arg1 arg2 and-so-on\n```\n\nYou can also execute run in build mode:\n\n```bash\nbashbox build --release --run -- arg1 arg2 and-so-on\n```\n\nNote: Don't pass `--run` in build command unless you want to auto-run it after compiling.\n\nA simple example:\n\n```bash\nbashbox build --release\n```\n\nFor more information try `bashbox --help`\n\n\n## Compiling bashbox\n\nIt's simple, just run `./bashbox build --release` after cloning this repository and bashbox will compile itself.\n\n## More things to write, this is incomplete at the moment\n\nPlease note that this project is very experimental and needs more work.\n\n## Caveats\n\nDon't do the followings\n\n- Masking error:\n```bash\nif test \"$(some_command --arg)\" == \"something\"; then {\n\tdo_something;\n} fi\n\n# Here due to the if statement it's impossible in bash to automatically catch the error within \"$(some_command --arg)\" subshell, which is why we need to assign it separately.\n```\n\u003e Solution:\n```bash\nlocal _var_foo;\n_var_foo=\"$(some_command --arg)\";\n\nif test \"$_var_foo\" == \"something\"; then {\n\tdo_something;\n} fi\n```\n\n- Undefined default variable in substitution:\n```bash\nlocal _argv=\"${1}\"; # Can fail # Imagine the user never passed any argument and thus undefined by nature.\n\nlocal _name_var=\"${SOME_ENV_VARIABLE}\"; # Can fail # You're assuming that some environment variable is available but it might not be and thus undefined.\n```\n\u003e Solution:\n```bash\nlocal _argv=\"${1:-}\";\n\nlocal _name_var=\"${SOME_ENV_VARIABLE:-}\";\n\n# We declare a one-time default value which is empty incase the variable was never defined just to make our program run. Later for safety all you should do is test whether your variable is empty or contains some data.\n```\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashbox%2Fbashbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbashbox%2Fbashbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbashbox%2Fbashbox/lists"}