mattn/go-shellwords

GitHub: mattn/go-shellwords

一个 Go 库,用于将单行文本按照 shell 语法规则解析为独立的单词参数。

Stars: 574 | Forks: 83

# go-shellwords [![codecov](https://codecov.io/gh/mattn/go-shellwords/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-shellwords) [![构建状态](https://travis-ci.org/mattn/go-shellwords.svg?branch=master)](https://travis-ci.org/mattn/go-shellwords) [![PkgGoDev](https://pkg.go.dev/badge/github.com/mattn/go-shellwords)](https://pkg.go.dev/github.com/mattn/go-shellwords) [![ci](https://github.com/mattn/go-shellwords/ci/badge.svg)](https://github.com/mattn/go-shellwords/actions) 将行解析为 shell 单词。 ## 用法 ``` args, err := shellwords.Parse("./foo --bar=baz") // args should be ["./foo", "--bar=baz"] ``` ``` envs, args, err := shellwords.ParseWithEnvs("FOO=foo BAR=baz ./foo --bar=baz") // envs should be ["FOO=foo", "BAR=baz"] // args should be ["./foo", "--bar=baz"] ``` ``` os.Setenv("FOO", "bar") p := shellwords.NewParser() p.ParseEnv = true args, err := p.Parse("./foo $FOO") // args should be ["./foo", "bar"] ``` ``` p := shellwords.NewParser() p.ParseBacktick = true args, err := p.Parse("./foo `echo $SHELL`") // args should be ["./foo", "/bin/bash"] ``` ``` shellwords.ParseBacktick = true p := shellwords.NewParser() args, err := p.Parse("./foo `echo $SHELL`") // args should be ["./foo", "/bin/bash"] ``` # 许可证 基于 MIT 许可证:http://mattn.mit-license.org/2017 # 作者 Yasuhiro Matsumoto (又名 mattn)
标签:EVTX分析, Go, Ruby工具, Shell, SOC Prime, 命令行参数, 字符串解析, 开发工具, 日志审计