• Stars
    star
    21
  • Rank 1,047,030 (Top 22 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords

License Go Report Card codecov GoDoc

A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

Installation

go get github.com/Wing924/shellwords

Usage

import "github.com/Wing924/shellwords"
args, err := shellwords.Split("./foo --bar=baz")
// args should be ["./foo", "--bar=baz"]

args, err := shellwords.Split("./foo 'a b c'")
// args should be ["./foo", "a b c"]
line := shellwords.Join([]string{"abc", "d e f"})
// line should be `abc d\ e\ f`
line := shellwords.Escape("./foo 'a b c'")
// line should be `./foo\ \'a\ b\ c\'\"`

Thanks

This is based on ruby module: Shellwords