https://github.com/vorpaljs/bash-parser
docker pull node:8.9.4-alpine
docker run -d --name node-alpine -it node:8.9.4-alpine
docker exec -it node-alpine /bin/sh
vi sample.js
var util = require('util');
const parse = require('bash-parser');
const ast = parse("/bin/?'c'ho$u 't'es't'");
console.log(util.inspect(ast, {colors: true, depth:10}));
node sample.js
{ type: 'Script',
commands:
[ { type: 'Command',
name:
{ text: '/bin/?\'c\'ho$u',
expansion:
[ { loc: { start: 11, end: 12 },
parameter: 'u',
type: 'ParameterExpansion' } ],
type: 'Word' },
suffix: [ { text: 'test', type: 'Word' } ] } ] }
docker stop node-alpine
docker rm node-alpine
docker images
docker image rm node-alpine