gg_shellquote

package
v0.2.54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2024 License: BSD-3-Clause, MIT Imports: 4 Imported by: 0

README

ShellQuote

ShellQuote provides utilities for joining/splitting strings using sh's word-splitting rules.

Functions:

  • Join: quote and join with spaces
  • Split: splits a string according to /bin/sh's word-splitting rules.

This package has been forked from the original work of Kevin Ballard: https://github.com/kballard/go-shellquote

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnterminatedSingleQuoteError = errors.New("Unterminated single-quoted string")
	UnterminatedDoubleQuoteError = errors.New("Unterminated double-quoted string")
	UnterminatedEscapeError      = errors.New("Unterminated backslash-escape")
)

Functions

This section is empty.

Types

type ShellQuoteHelper

type ShellQuoteHelper struct {
}
var ShellQuote *ShellQuoteHelper

func (*ShellQuoteHelper) Join

func (instance *ShellQuoteHelper) Join(args ...string) string

Join quotes each argument and joins them with a space. If passed to /bin/sh, the resulting string will be split back into the original arguments.

func (*ShellQuoteHelper) Split

func (instance *ShellQuoteHelper) Split(input string) (words []string, err error)

Split splits a string according to /bin/sh's word-splitting rules. It supports backslash-escapes, single-quotes, and double-quotes. Notably it does not support the $” style of quoting. It also doesn't attempt to perform any other sort of expansion, including brace expansion, shell expansion, or pathname expansion.

If the given input has an unterminated quoted string or ends in a backslash-escape, one of UnterminatedSingleQuoteError, UnterminatedDoubleQuoteError, or UnterminatedEscapeError is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL