shq
Quote a string for safe use as a shell argument. Strips null characters.
Last updated 6 years ago by mk-pmb .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install shq 
SYNC missed versions from official npm registry.

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

Current Tags

  • 1.0.2                                ...           latest (6 years ago)

3 Versions

  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 2
Last Month 1
Dependencies (0)
None
Dev Dependencies (1)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |