{"id":19388942,"url":"https://github.com/james2doyle/lit-sh","last_synced_at":"2026-05-16T19:35:52.464Z","repository":{"id":145775200,"uuid":"41973363","full_name":"james2doyle/lit-sh","owner":"james2doyle","description":"Tiny lit module to manage shell commands (Modified from zserge/luash).","archived":false,"fork":false,"pushed_at":"2015-09-05T20:12:04.000Z","size":144,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-07T08:49:08.012Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/james2doyle.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}},"created_at":"2015-09-05T19:43:01.000Z","updated_at":"2018-07-02T13:02:48.000Z","dependencies_parsed_at":"2023-04-07T03:56:47.798Z","dependency_job_id":null,"html_url":"https://github.com/james2doyle/lit-sh","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/james2doyle%2Flit-sh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Flit-sh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Flit-sh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Flit-sh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/james2doyle","download_url":"https://codeload.github.com/james2doyle/lit-sh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240549434,"owners_count":19819131,"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":[],"created_at":"2024-11-10T10:14:08.903Z","updated_at":"2026-05-16T19:35:47.442Z","avatar_url":"https://github.com/james2doyle.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"sh\n=======\n\nTiny lit module to manage shell commands (Modified from [zserge/luash](https://github.com/zserge/luash)).\n\n### Install\n\n```sh\n$ lit install james2doyle/sh\n```\n\n### Usage\n\nUnlike [zserge/luash](https://github.com/zserge/luash), we do not expose anything to `_G`. Instead this module just uses the `sh.command` function directly.\n\n**Simple Usage**\n\nThe `sh.command` function returns a function. Calling the returning function of `sh.command`, runs the command.\n\n```lua\nlocal sh = require('sh')\n\nlocal e = sh.command('echo', 'hello world')\nprint(e()) -- prints \"hello world\"\n```\n\nYou can nest commands inside each other.\n\n```lua\nlocal sh = require('sh')\n\nlocal sedecho = sh.command('sed', 's/world/Lua/g')(sh.command('echo', 'hello', 'world')())\nprint('output:', sedecho) -- prints \"output: hello Lua\"\n```\n\n**Full Examples**\n\n```lua\nlocal sh = require('sh')\n\n-- any shell command can be called as a function\nprint('User:', sh.command('whoami')())\nprint('Current directory:', sh.command('pwd')())\n\n-- commands can be grouped into the pipeline as nested functions\nlocal bin = sh.command('wc')(sh.command('ls', '-l', '/bin')())\nprint('Files in /bin:', bin)\nlocal usrbin = sh.command('wc')(sh.command('ls', '-l', '/usr/bin')())\nprint('Files in /usr/bin:', usrbin)\nlocal bothbins = sh.command('wc')(sh.command('ls', '-l', '/usr/bin')(), sh.command('ls', '-l', '/bin')())\nprint('files in both /usr/bin and /bin:', bothbins)\n\n-- intermediate output in the pipeline can be stored into variables\nlocal sedecho = sh.command('sed', 's/world/Lua/g')(sh.command('echo', 'hello', 'world')())\nprint('output:', sedecho)\nprint('exit code:', sedecho.__exitcode)\nlocal res = sh.command('tr', '[[:lower:]]', '[[:upper:]]')(sedecho)\nprint('output+tr:', res)\n\n-- command functions can be created dynamically. Optionally, some arguments\n-- can be prepended (like partially applied functions)\nlocal e = sh.command('echo')\nlocal greet = sh.command('echo', 'hello')\nprint(e('this', 'is', 'some', 'output'))\nprint(greet('world'))\nprint(greet('foo'))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Flit-sh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames2doyle%2Flit-sh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Flit-sh/lists"}