{"id":15942166,"url":"https://github.com/discretetom/esc4sh","last_synced_at":"2026-04-08T18:31:30.565Z","repository":{"id":207344225,"uuid":"718974919","full_name":"DiscreteTom/esc4sh","owner":"DiscreteTom","description":"Escape a string to use it in shell. Support both linux and windows (cmd and powershell).","archived":false,"fork":false,"pushed_at":"2023-12-27T13:57:02.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T05:03:33.116Z","etag":null,"topics":["cmd","escape","javascript","nodejs","powershell","shell","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/DiscreteTom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-11-15T07:16:42.000Z","updated_at":"2023-11-15T09:26:32.000Z","dependencies_parsed_at":"2023-11-15T10:35:40.682Z","dependency_job_id":"7253d9ae-f3bb-46f2-8f17-1bda1840c39a","html_url":"https://github.com/DiscreteTom/esc4sh","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"4a2eb9839e2ab4ba422d0467053501fb544c3b19"},"previous_names":["discretetom/esc4sh"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fesc4sh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fesc4sh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fesc4sh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DiscreteTom%2Fesc4sh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DiscreteTom","download_url":"https://codeload.github.com/DiscreteTom/esc4sh/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247078867,"owners_count":20879953,"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":["cmd","escape","javascript","nodejs","powershell","shell","typescript"],"created_at":"2024-10-07T07:40:29.695Z","updated_at":"2025-12-30T23:09:34.786Z","avatar_url":"https://github.com/DiscreteTom.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esc4sh\n\n[![npm](https://img.shields.io/npm/v/esc4sh?style=flat-square)](https://www.npmjs.com/package/esc4sh)\n![coverage](https://img.shields.io/codecov/c/github/DiscreteTom/esc4sh?style=flat-square)\n![build](https://img.shields.io/github/actions/workflow/status/DiscreteTom/esc4sh/publish.yml?style=flat-square)\n![license](https://img.shields.io/github/license/DiscreteTom/esc4sh?style=flat-square)\n\nEscape a string to use it in shell. Support both linux and windows (cmd and powershell).\n\nTry it online in the [playground](https://dttk.discretetom.com/js-playground?crushed=%28%27dependencieG%27https%253A%252F%252Fcdn.jsdelivr.net%252FnpmO%25400.1.2%252FdistO.min.js%27%255D%7EcellGJPrepareClib-*BI%28E4cmdM4psM%2520%29NB*N.*Ftrue%7Eid%21D787179%29%252CJCs-*%257B%255C%27%2524PATH%255C%27%257DBBLole.log%257Bs%257DFfalse%7Eid%21K%29%255D%7EpanelGK%255D%29*esc4sh-%2520%253D%2520B%255Cr%255CnC%27%7Ecode%21%27ID1703684E%2520escF%27%7Ereadonly%21Gs%21%255BILt%2520J%28%27name%21%27KD847765LconsM%252CEN-libO%252F*%2501ONMLKJIGFEDCB-*_).\n\n## Install\n\n```bash\nyarn add esc4sh\n```\n\n## Usage\n\nAuto detect os and shell (not working in browser):\n\n```ts\nimport { Manager } from \"esc4sh\";\n\nconst manager = new Manager();\nmanager.escape(\"something\");\n\n// use Array.map to escape multiple strings\n// and join them with space to form an executable command\nconst cmd = [\"curl\", ...options.map((o) =\u003e manager.escape(o))].join(\" \");\n```\n\nExplicitly specify shell. These can be used in browser.\n\n```ts\nimport { esc4sh, esc4cmd, esc4ps, esc } from \"esc4sh\";\n\n// linux sh/bash\nconsole.log(esc4sh(\"$PATH\")); // =\u003e '$PATH'\n// windows cmd\nconsole.log(esc4cmd(\"%PATH$\")); // =\u003e \"%PATH%\"\n// windows powershell\nconsole.log(esc4ps(\"$env:PATH\")); // =\u003e '$env:PATH'\n\n// escape by options\nesc(\"\"); // for linux sh/bash\nesc(\"\", { windows: true }); // for windows cmd\nesc(\"\", { windows: true, powershell: true }); // for windows powershell\n```\n\nHelpers (not working in browser).\n\n```ts\nimport { isWindows, isCmd, isPowershell } from \"esc4sh\";\n\nisWindows(); // =\u003e boolean\nisCmd(); // =\u003e boolean\nisPowershell(); // =\u003e boolean\n```\n\n## Credit\n\nThis project is inspired by [xxorax/node-shell-escape](https://github.com/xxorax/node-shell-escape/) and [boazy/any-shell-escape](https://github.com/boazy/any-shell-escape/).\n\n## [CHANGELOG](./CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscretetom%2Fesc4sh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscretetom%2Fesc4sh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscretetom%2Fesc4sh/lists"}