
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
node-shlex
is a Node.js module for quoting and parsing shell commands.
The API was inspired by the shlex
module from the Python Standard
Library. However, the Python implementation is fairly complex, and supports a
confusing matrix of modes that is not replicated here. node-shlex
always
operates in what the Python module calls "POSIX mode."
As of version 2.0.0, Bash's ANSI C strings ($'x'
) and
locale-specific translation strings ($"x"
) are supported. This
diverges from the Python shlex
behavior but makes parsing more accurate.
Note that node-shlex
does not attempt to split on or otherwise parse
operators (such as 2>/dev/null
) or comments, and it does not perform variable interpolation.
shlex.join()
var join = require("shlex").join
join(["ls", "-al", '/']) // returns: 'ls -al /'
join([ 'rm', '-f', '/Volumes/Macintosh HD' ]) // returns: "rm -f '/Volumes/Macintosh HD'"
shlex.quote()
var quote = require("shlex").quote
quote("abc") // returns: abc
quote("abc def") // returns: 'abc def'
quote("can't") // returns: 'can'"'"'t'
shlex.split()
var split = require("shlex").split
split('ls -al /') // returns: [ 'ls', '-al', '/' ]
split('rm -f "/Volumes/Macintosh HD"') // returns: [ 'rm', '-f', '/Volumes/Macintosh HD' ]
FAQs
Node.js port of Python's shlex shell-like lexer
The npm package shlex receives a total of 131,365 weekly downloads. As such, shlex popularity was classified as popular.
We found that shlex demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.