Wing924 / shellwords

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

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

License:Apache License 2.0


Languages

Language:Go 100.0%