{"id":30808512,"url":"https://github.com/romw314/bashgenn","last_synced_at":"2025-09-06T03:14:03.962Z","repository":{"id":214668994,"uuid":"633459995","full_name":"romw314/bashgenn","owner":"romw314","description":"Original Bashgenn - BASH script GENerator for text maNipulation.","archived":false,"fork":false,"pushed_at":"2024-06-24T12:18:00.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-24T13:48:30.854Z","etag":null,"topics":["bash","bash-script","bashgenn","cli","cli-tool","command-line","command-line-tool","compiler","custom-programming-language","install","install-script","programming-language","transpiler"],"latest_commit_sha":null,"homepage":"https://bashgenn-docs.rtfd.io","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/romw314.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-04-27T14:43:27.000Z","updated_at":"2024-06-24T13:48:33.180Z","dependencies_parsed_at":"2024-02-02T12:30:00.521Z","dependency_job_id":"9e9c9fa8-9c22-4175-80ca-0d4ed75e277c","html_url":"https://github.com/romw314/bashgenn","commit_stats":null,"previous_names":["romw314/bashgenn"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/romw314/bashgenn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romw314%2Fbashgenn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romw314%2Fbashgenn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romw314%2Fbashgenn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romw314%2Fbashgenn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romw314","download_url":"https://codeload.github.com/romw314/bashgenn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romw314%2Fbashgenn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273851454,"owners_count":25179439,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","bash-script","bashgenn","cli","cli-tool","command-line","command-line-tool","compiler","custom-programming-language","install","install-script","programming-language","transpiler"],"created_at":"2025-09-06T03:13:42.426Z","updated_at":"2025-09-06T03:14:03.951Z","avatar_url":"https://github.com/romw314.png","language":"Shell","readme":"\u003c!--\n\n# BASHGENN IS DEPRECATED: [RBGN](https://github.com/romw314/rust-bashgenn) IS A MODERN ALTERNATIVE TO BASHGENN. IF YOU STILL NEED TO USE BASHGENN, TRY TO WRITE SCRIPTS WITHOUT ANY BASHGENN-SPECIFIC COMMANDS!\n\nRBGN is a new, cross-platform and modern Bashgenn interpreter written in Rust. RBGN is currently in development and if you need Bashgenn-specific features, use Bashgenn. **YOU SHOULD NOT USE BASHGENN IF RBGN CAN RUN YOUR SCRIPT PROPERLY.**\n\nUsing RBGN is very simple. First of all, you need to [install Rust](https://rustup.rs). Then, you need to install RBGN (if you are on Windows, run it with Powershell):\n\n```sh\ncargo install --git https://github.com/romw314/rust-bashgenn.git\n```\n\nWhen you have RBGN installed, you can run any script by running this command (replace `/path/to/your/script.bgn` with the actual path to the Bashgenn script you want to run):\n\n```sh\nrbgn -i /path/to/your/script.bgn\n```\n\nTo get help about RBGN, run this command:\n\n```sh\nrbgn --help\n```\n\n--\u003e\n\n# Bashgenn\n\nBashgenn - the ***Bash*** script ***gen***erator for text ma***n***iputaion.\n\nBashgenn is a simple programming language for text manipulation.\n\n[![Replit](https://img.shields.io/badge/Replit-template-green?style=for-the-badge\u0026logo=replit)](https://replit.com/@romw314/Bashgenn?v=1#main.bgn)\n[![License](https://img.shields.io/github/license/romw314/bashgenn?style=for-the-badge)\n](https://github.com/romw314/bashgenn/tree/master?tab=Unlicense-1-ov-file)\n\n## Installation\n\nBashgenn can be installed from RAPR (Debian/Ubuntu only, make sure you have [RAPR](https://romw314.github.io/rapr.html) set up first):\n\n```sh\nsudo apt-get install bashgenn\n```\n\nOn other operating systems, use the install script:\n\n```sh\ncurl -s https://tinyurl.com/bginst3-linux | bash\n```\n\nBashgenn can also be installed by cloning this repo and adding the `bashgenn` script to your PATH:\n\n```sh\ngit clone https://github.com/romw314/bashgenn\ncd bashgenn\ncp bashgenn ~/.local/bin/\n```\n\nOr install it per-machine:\n\n```sh\ngit clone https://github.com/romw314/bashgenn\ncd bashgenn\nsudo cp bashgenn /usr/local/bin/\n```\n\n## Tutorial\n\nBashgenn scripts always read from standard input and write to standard output. They don't have any other input or output.\n\nBashgenn scripts are created from **commands**. Each command has it's own line in our file and must be written UPPERCASE. Each command can have up to 2 arguments, separated by spaces.\n\nThere are also variables. Variables does not have their types, they are always strings (or numbers stored as strings).\n\nThe most basic commands in Bashgenn are `PROG_INIT`, `DECLARE`, `READ` and `ECHO`.\n\n`PROG_INIT` must always be placed at the beginning of the script.\n\n`DECLARE` initializes a variable with an empty string. `DECLARE` takes one argument - the variable name to initialize. Variables cannot be used before initialized.\n\n`READ` reads one line of input and saves it to a variable. `READ` takes one argument - the name of the variable to save the input in.\n\n`ECHO` writes data from a variable to the output. `ECHO` takes one argument - the name of the variable to write the data from.\n\nHere is a basic script which reads one line and prints it out:\n\n```\nPROG_INIT\nDECLARE our_variable\nREAD our_variable\nECHO our_variable\n```\n\nWe can compile and run the script by saving it into a file named `our_script.bgn` and running the following commands:\n\n```sh\nbashgenn our_script.bgn\n./bg-f\n```\n\nPlease note that Bashgenn always saves the output script to a file named `bg-f`. There's no option to change the output file. It also can't compile the script to a binary, it compiles it only to a Bash script.\n\nWe can also write the text three times:\n\n```\nPROG_INIT\nDECLARE our_variable\nREAD our_variable\nECHO our_variable\nECHO our_variable\nECHO our_variable\n```\n\nAnd if we want to write the text 500 times? Should we add the `ECHO` command 500 times? No! The `REPEAT` command is designed for that:\n\n```\nPROG_INIT\nDECLARE our_variable\nREAD our_variable\nREPEAT 500\n  ECHO our_variable\nDONE\n```\n\nWe can also read and write out two lines:\n\n```\nPROG_INIT\nDECLARE our_variable\nDECLARE another_variable\nREAD our_variable\nREAD another_variable\nECHO our_variable\nECHO another_variable\n```\n\nNow, it's time for practice. Adapt the code above to write the two lines in reversed order. When we enter this input:\n\n```\nHello\nWorld\n```\n\nThe output should be:\n\n```\nWorld\nHello\n```\n\n\u003cdetails\u003e\u003csummary\u003eClick to expand the solution\u003c/summary\u003e\n  \n```\nPROG_INIT\nDECLARE our_variable\nDECLARE another_variable\nREAD our_variable\nREAD another_variable\nECHO another_variable\nECHO our_variable\n```\n\n\u003c/details\u003e\n\nHow to write a script that just prints `Hello, World!`, without any input? The `CONST_SET` command and the `CONST_WRITE` command are designed for that. We create a **constant** (not a variable) and copy it to a variable. Then, we write out the variable. Please note that we need to add `_OPT ireq true` before `PROG_INIT` in order to use `CONST_WRITE`.\n\n```\n_OPT ireq true\nPROG_INIT\nDECLARE our_variable\nCONST_SET our_constant Hello, World!\nCONST_WRITE our_constant our_variable  \nECHO our_variable\n```\n\nIn bashgenn lines starting with `-` are comments, for example:\n```\nPROG_INIT\n- This is a comment,\n- comments are ignored\n- by the compiler.\n\n- This script does not do anything.\n```\n\nNext, we'll try to reverse a string (for example `olleh` from `hello`):\n```\n- This script is slow because we reverse the string character by character.\nPROG_INIT\n\n- Initialize variables\nDECLARE last\nDECLARE input\nDECLARE result\n\n- Read the input into a variable named `input`\nREAD input\n\n- STRGET repeats the commands inside until the variable in the first argument\n- (in this case `input`) is not an empty string.\nSTRGET input\n  - This command removes the last character from the variable `input`\n  - and saves it in the `last` variable.\n  STORELAST input last\n  - This appends the data from the `last` variable\n  - to the end of the `result` variable.\n  - Please note that the variable is empty at the beginning.\n  STRCAT last result\nDONE\n\n- When we move all characters from the input to the result\n- (this also reverses the string because we always move\n- the last character of the input to the end of the result),\n- we write out the result.\nECHO result\n```\n\nIf you want to write to a file, you need to use [BgBase](https://github.com/romw314/bgbase) - a library for Bashgenn. Bashgenn scripts without BgBase read only from standard input and write to standard output.\n\nAfter installing BgBase, you can write `Hello, world!` to a file named `hello.txt` using this script:\n\n```\n- This is needed if you want to import modules.\nMODULE main\n- This is needed for CONST_WRITE.\n_OPT ireq true\nPROG_INIT\n- This imports the io module from BgBase.\nIMPORT io\n\n- Set the filename. The filename must be in the bgfile variable. No other variable names work.\nCONST_SET filename hello.txt\nCONST_WRITE filename bgfile\n\n- Set the data to write to the file. The data must be in the bgdata variable.\nCONST_SET our_data Hello, world!\nCONST_WRITE our_data bgdata\n\n- This writes to the file. You need to set the bgdata and the bgfile variable before this.\n- The io module must be imported.\nUSE io.writefile\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromw314%2Fbashgenn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromw314%2Fbashgenn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromw314%2Fbashgenn/lists"}