shq

shq

Quote a string for safe use as a shell argument. Strips null characters.

Showing:

Popularity

Downloads/wk

7K

GitHub Stars

8

Maintenance

Last Commit

1yr ago

Contributors

1

Package

Dependencies

0

Size (min+gzip)

0.4KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

shq

Quote a string for safe use as a shell argument. Strips null characters.

API

This module ESM-exports one function that holds some methods:

shq(x)

  • Stringify x,
  • remove all U+0000 null characters, because all too often, some C program in the pipeline will screw it up even if properly quoted,
  • and in case it contains special characters, quote it.

shq.cfg(opt)

Return a customized quoting function. opt is an optional options object that supports these keys:

  • empty: How to represent the empty string. Default: A pair of single quotes.
  • gratuitous: What string to put on both sides of a non-empty input that doesn't need to be quoted.

shq.always

A quoting function that adds gratuitous single quotes (cf. .cfg).

Usage

see test.usage.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

ISC

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial