{"id":18883579,"url":"https://github.com/qaqland/dotlua","last_synced_at":"2025-04-14T20:31:03.448Z","repository":{"id":250568124,"uuid":"834773510","full_name":"qaqland/dotlua","owner":"qaqland","description":"dotlua help to run lua code with bash shell","archived":false,"fork":false,"pushed_at":"2024-08-14T08:20:58.000Z","size":22,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T08:51:18.331Z","etag":null,"topics":["bash","builtin","lua","script"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qaqland.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":"2024-07-28T10:14:40.000Z","updated_at":"2025-01-20T08:35:40.000Z","dependencies_parsed_at":"2024-11-10T09:45:13.157Z","dependency_job_id":null,"html_url":"https://github.com/qaqland/dotlua","commit_stats":null,"previous_names":["qaqland/dotlua"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaqland%2Fdotlua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaqland%2Fdotlua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaqland%2Fdotlua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qaqland%2Fdotlua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qaqland","download_url":"https://codeload.github.com/qaqland/dotlua/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248955432,"owners_count":21189102,"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","builtin","lua","script"],"created_at":"2024-11-08T07:02:30.859Z","updated_at":"2025-04-14T20:31:03.187Z","avatar_url":"https://github.com/qaqland.png","language":"C","readme":"# dotlua\n\ndotlua help to run lua code with bash shell\n\n- Call lua function from shell and vice versa\n- Get, set and export shell variables directly from lua\n\n## Usage\n\n```bash\n$ enable -f path/to/dotlua.so dotlua\n\n# dot lua\n$ dotlua -s 'print(_VERSION)'\n\n# remove\n$ enable -d dotlua\n```\n\nIt is recommended to start your bash script with `env`\n\n```bash\n#!/usr/bin/env bash\n```\n\n## Setup\n\n```bash\n# apk add bash (?)\n# apk add meson\n# apk add lua5.4-dev bash-dev\n\nmeson setup builddir\nmeson compile -C builddir\n```\n\n## CLI\n\n### Source File\n\n```bash\n$ dotlua FILE [ARGUMENTS ...]\n```\n\n### Call Function\n\n```bash\n$ dotlua [-r] -f FUNCTION [ARGUMENTS ...]\n```\n\nOption `-r` allow you to call the raw function.\n\n### Execute String\n\n```bash\n$ dotlua -s \"LUA STRING\"\n```\n\n### List Lua Bindings\n\n```bash\n$ dotlua -l [PATTERN]\n```\n\n## API\n\nSet env `DOTLUA_PREFIX` to override default namespace `sh`\n\n### `sh.put()`\n\n```lua\n-- export foo\nsh.put(\"foo\")\n\n-- export foo=bar\nsh.put(\"foo\", \"bar\")\n```\n\n### `sh.set()`\n\n```lua\n-- foo=bar\nsh.set(\"foo\", \"bar\")\n```\n\n### `sh.get()`\n\n```lua\n-- $foo\nsh.get(\"foo\")\n```\n\n### `sh.delete()`\n\n```lua\n-- unset foo\nsh.delete(\"foo\")\n```\n\n### `sh.bind()`\n\n```lua\nsh.bind(\"add_2_number\")\nsh.bind(\"add-2-number\", add_2_number)\n```\n\nCall lua function from shell after binding\n\n### `sh.call()`\n\n```lua\nsh.call(\"call_two\", 1, 2)\n```\n\nCall shell function from lua\n\n### `sh.F`\n\nStore function bindings\n\n## TODO\n\n- [x] `dotlua xxx.lua`\n- [x] `dotlua xxx.lua -- args`\n- [x] `dotlua -s \"string lua\"`\n- [x] `dotlua -f function args`\n- [x] `dotlua -l match`\n- [x] call shell built-ins\n- [x] call shell `cd`\n- [x] lua c api fix\n- [ ] valgrind check\n- [x] clang format\n- [ ] catch stdout/stderr?\n- [x] lua function return\n- [x] put (export)\n- [x] delete (unset)\n\n## Test\n\n```bash\n# apk add bats\n\nbats tests\n```\n\n## LICENSE\n\nCopyright (C) 2024 qaqland\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see \u003chttps://www.gnu.org/licenses/\u003e.\n\n## Acknowledge\n\nThis project is highly inspired by [LuaBash][1].\n\nStart to make your own builtin from this [blog][2] and get more builtin example\nand details in [bash_builtin][3] and [bash][4] itself.\n\n[1]: https://github.com/alfredopalhares/LuaBash\n[2]: https://blog.dario-hamidi.de/a/build-a-bash-builtin\n[3]: https://github.com/cjungmann/bash_builtin\n[4]: http://git.savannah.gnu.org/cgit/bash.git/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaqland%2Fdotlua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqaqland%2Fdotlua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqaqland%2Fdotlua/lists"}