{"id":13803497,"url":"https://github.com/refcell/unix","last_synced_at":"2025-07-07T16:39:14.296Z","repository":{"id":43767899,"uuid":"511592824","full_name":"refcell/unix","owner":"refcell","description":"A lightweight, extensible foundry library for shell scripting.","archived":false,"fork":false,"pushed_at":"2022-07-12T22:48:58.000Z","size":503,"stargazers_count":62,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-20T00:12:35.614Z","etag":null,"topics":["evm","foundry","script","solidity"],"latest_commit_sha":null,"homepage":"","language":"Solidity","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/refcell.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":"2022-07-07T16:05:02.000Z","updated_at":"2024-11-01T16:55:18.000Z","dependencies_parsed_at":"2022-07-12T18:19:32.312Z","dependency_job_id":null,"html_url":"https://github.com/refcell/unix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/refcell/unix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Funix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Funix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Funix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Funix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refcell","download_url":"https://codeload.github.com/refcell/unix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refcell%2Funix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261044118,"owners_count":23101823,"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":["evm","foundry","script","solidity"],"created_at":"2024-08-04T01:00:33.905Z","updated_at":"2025-07-07T16:39:14.232Z","avatar_url":"https://github.com/refcell.png","language":"Solidity","funding_links":[],"categories":["Templates \u0026 Libraries"],"sub_categories":[],"readme":"\u003cimg align=\"right\" width=\"150\" height=\"150\" top=\"100\" src=\"./assets/unix.png\"\u003e\n\n# unix • [![ci](https://github.com/abigger87/unix/actions/workflows/ci.yaml/badge.svg?label=ci)](https://github.com/abigger87/unix/actions/workflows/ci.yaml) [![license](https://img.shields.io/badge/License-Apache_2.0-blue.svg?label=license)](https://opensource.org/licenses/Apache-2.0) [![size](https://img.shields.io/github/languages/code-size/abigger87/unix.svg?color=orange\u0026label=size)](https://img.shields.io/github/languages/code-size/abigger87/unix?label=size) ![solidity](https://img.shields.io/badge/solidity-%3E%3D0.8.13%20%3C0.9.0-lightgrey)\n\nA **lightweight**, **extensible** [foundry](https://github.com/foundry-rs/foundry) library for shell scripting.\n\n\n## What?\n\n**unix** is an extensible wrapper for common unix shell commands. It provides a minimal api for executing expressive shell commands from inside Solidity using [foundry](https://github.com/foundry-rs/foundry)'s [fii](https://book.getfoundry.sh/cheatcodes/ffi.html).\n\n\n## Installation\n\n```\nforge install abigger87/unix\n```\n\n## Usage\n\n_NOTE: You must enable [ffi](https://book.getfoundry.sh/cheatcodes/ffi.html) in order to use this library. You can either pass the `--ffi` flag to any forge commands you run (e.g. `forge script Script --ffi`), or you can add `ffi = true` to your `foundry.toml` file._\n\n_NOTE: **unix** assumes you are running on a UNIX based machine with `bash`, `tail`, `sed`, `tr`, `curl` and `cast` installed._\n\n\n1. Add this import to your script or test:\n```solidity\nimport {Unix} from \"unix/Unix.sol\";\n```\n\n2. Add this directive inside of your Contract:\n```solidity\nusing Unix for *;\n```\n\n3. Run your shell commands. This can be done in two ways:\n\na) Using strong typing **(recommended)**:\n```solidity\n// Echo \"Hello World\"\n(uint256 status, bytes memory data) = Unix.echo().stdout(\"Hello World\").run();\n\n// Pipe file contents to another file\n// NOTE: Commands can be instantiated from a text string using `Command.from(\u003cYOUR_STRING\u003e)` _(see grep command below)_\n(uint256 status, bytes memory data) = Unix.cat().file(\"README.md\").pipe(Command.from(\"grep \\\"Hello\\\")).run();\n```\n\nb) Using raw string commands.\n```solidity\n// Cat a file\n(uint256 status, bytes memory data) = \"cat README.md\".run();\n// string(data) == \u003ccontents of README.md\u003e\n\n// Echo a string\n(uint256 status, bytes memory data) = \"echo Hello World\".run();\n// string(data) == \"Hello World\"\n\n// Print the working directory\n(uint256 status, bytes memory data) = \"pwd\".run();\n// string(data) == \u003cworking directory\u003e\n```\n\nWe have provided extensive examples in [scripts](./script/) and further completeness is demonstrated in [tests](./test/Unix.t.sol).\n\nTo run scripts, simply prefix the script name with `forge s` like so: `forge s \u003cscript_name\u003e`. For example, to run the [echo](./script/echo.s.sol) script, run: `forge s echo`.\n\n\n## Contributing\n\n_NOTE: This library is built using [Foundry](https://getfoundry.sh). To learn more about foundry and its usage, please refer to [foundry book](https://book.getfoundry.sh/getting-started/installation.html)._\n\nAll contributions are welcome! We want to make contributing to this project as easy and transparent as possible, whether it's:\n  - Reporting a bug\n  - Discussing the current state of the code\n  - Submitting a fix\n  - Proposing new features\n  - Becoming a maintainer\n\nWe use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/abigger87/unix/issues/new); it's that easy!\n\nTo run tests, install and update modules with `forge update` and run `forge test` to run all tests!\n\n\n## Safety\n\nThis is **experimental software** and is provided on an \"as is\" and \"as available\" basis.\n\nWe **do not give any warranties** and **will not be liable for any loss** incurred through any use of this codebase.\n\n\n## Acknowledgements\n\n- [Shannon](https://github.com/abigger87/shannon) _(SOON™)_\n- [Surl](https://github.com/memester-xyz/surl)\n- [Solenv](https://github.com/memester-xyz/solenv)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefcell%2Funix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefcell%2Funix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefcell%2Funix/lists"}