First off, a disclaimer, this is not supposed to be a full Lua implementation of the Python shlex module. It is a simplified version to fit my purposes.
This is not a rock, it's not worthy of a rock really. It's more a couple files you can drop into your project (or even your Neovim config (which is why I wrote it)) if you need to parse a shell command.
local shlex = require 'shlex'
local parts = shlex.split('some command/with/parts')
print(require('inspect')(parts))
-- {'some', 'command/with/parts'}
local cmd = shlex.join(parts)
print(cmd)
-- "'some' 'command/with/parts'"
- No file sources, it takes a string and a string alone
- Comments are enabled by default (I'm not really sure why this is disabled by default in shlex)
Simple set of tests, easy to add your own if you want to know if this file will work for you.
$ lua shlex-tests.lua
Test: Simple command
cmd: cat /some/file
exp: { "cat", "/some/file" }
res: success
Test: Quoted argument
cmd: cat '/some/file'
exp: { "cat", "/some/file" }
res: success
...