]> git.lizzy.rs Git - micro.git/blob - cmd/micro/shellwords/README.md
Code optimisation (#1117)
[micro.git] / cmd / micro / shellwords / README.md
1 This is a modified version of `go-shellwords` for the micro editor.
2
3 # go-shellwords
4
5 [![Coverage Status](https://coveralls.io/repos/mattn/go-shellwords/badge.png?branch=master)](https://coveralls.io/r/mattn/go-shellwords?branch=master)
6 [![Build Status](https://travis-ci.org/mattn/go-shellwords.svg?branch=master)](https://travis-ci.org/mattn/go-shellwords)
7
8 Parse line as shell words.
9
10 ## Usage
11
12 ```go
13 args, err := shellwords.Parse("./foo --bar=baz")
14 // args should be ["./foo", "--bar=baz"]
15 ```
16
17 ```go
18 os.Setenv("FOO", "bar")
19 p := shellwords.NewParser()
20 p.ParseEnv = true
21 args, err := p.Parse("./foo $FOO")
22 // args should be ["./foo", "bar"]
23 ```
24
25 ```go
26 p := shellwords.NewParser()
27 p.ParseBacktick = true
28 args, err := p.Parse("./foo `echo $SHELL`")
29 // args should be ["./foo", "/bin/bash"]
30 ```
31
32 ```go
33 shellwords.ParseBacktick = true
34 p := shellwords.NewParser()
35 args, err := p.Parse("./foo `echo $SHELL`")
36 // args should be ["./foo", "/bin/bash"]
37 ```
38
39 # Thanks
40
41 This is based on cpan module [Parse::CommandLine](https://metacpan.org/pod/Parse::CommandLine).
42
43 # License
44
45 under the MIT License: http://mattn.mit-license.org/2017
46
47 # Author
48
49 Yasuhiro Matsumoto (a.k.a mattn)