Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mossop/shell-args
Parsing and quoting for shell command lines that supports both bash and windows styles of quoting.
https://github.com/mossop/shell-args
api javascript nodejs typescript
Last synced: 26 days ago
JSON representation
Parsing and quoting for shell command lines that supports both bash and windows styles of quoting.
- Host: GitHub
- URL: https://github.com/mossop/shell-args
- Owner: Mossop
- Created: 2020-04-06T18:42:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T22:50:47.000Z (almost 2 years ago)
- Last Synced: 2024-10-07T21:09:12.531Z (about 1 month ago)
- Topics: api, javascript, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.08 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# shell-args
A simple set of functions for parsing a command line string into arguments and converting command
line arguments into a correctly escaped string.Many other npm modules offer this functionality however the only ones I could find only support
unix style escaping and so do not work correctly for windows command lines.This module exports `bashShellParse`, `winShellParse`, `bashShellQuote` and `winShellQuote`. It
also exports `shellQuote` and `shellParse` which call the function correct for the current platform.The parse functions accept a string and return an array of strings:
```javascript
import { bashShellQuote } from "shell-args";bashShellParse("hello there world"); // -> ["hello", "there", "world"]
bashShellParse("\"hello there\" world"); // -> ["hello there", "world"]
bashShellParse(`foo
test\\(\\)`); // -> ["foo", "test()"]
```The quote functions accept an array of strings and return a string:
```javascript
import { bashShellParse } from "shell-args";bashShellQuote(["hello", "there", "world"]); // -> "hello there world"
bashShellQuote(["hello there", "world"]); // -> "\"hello there\" world"
bashShellQuote(["foo", "test()"]); // -> ["foo", "test\\(\\)"]
```