Skip to content

Manipulate strings according to the word parsing rules of the UNIX Bourne shell.

License

Notifications You must be signed in to change notification settings

marques-work/shellwords

 
 

Repository files navigation

Shellwords-TS

Build Status

A JavaScript port of the Ruby module of the same name, with TypeScript typings. Shellwords provides functions to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Originally forked from jimmycuadra/shellwords, this package is updated to be at parity with a modern reference implementation (Ruby 3.1.2 at the time of writing) and implements Shellwords.join(), which was missing from the original package. The goal of this is to maintain parity with the Ruby Shellwords module, so if there is a discrepancy, please file a bug (or even better, a PR).

Installation

Add "shellwords-ts" to your package.json file and run npm install.

Example

import Shellwords from "shellwords-ts";

Shellwords.split("foo 'bar baz'"); // ["foo", "bar baz"]
Shellwords.escape("What's up?"); // "What\\'s\\ up\\?"
Shellwords.join(["find", "~/Library/Application Support", "-name", "*.plist"]); // "find \\~/Library/Application\\ Support -name \\*.plist"

Shellwords.split("foo 'bar baz' quu", (rawPart) => {
  // have access to the chunks of the raw string as it is scanned
});

Breaking changes as of 3.0.0:

About

Manipulate strings according to the word parsing rules of the UNIX Bourne shell.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 70.6%
  • JavaScript 29.4%