shellutil

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTrailingBackslash = errors.New("trailing backslash")

Error of the POSIX splitters for a backslash ending the input with nothing left to escape

View Source
var ErrUnterminatedQuote = errors.New("unterminated quote")

Error of the splitters for a quote that is never closed

Functions

func Join

func Join(args []string) string

Arguments quoted for a POSIX shell and joined by single spaces, the first also quoted when bare it would be read as a variable assignment, a reserved word or a job rather than the command it names

func Quote

func Quote(s string) string

One argument quoted for a POSIX shell: as is when every byte is a letter, a digit or one of _@%+=:,./- and it does not start with the = that zsh expands to a command path, otherwise in single quotes

func Split

func Split(s string) ([]string, error)

Words of s split the way a POSIX shell splits them: blanks separate words, single quotes keep everything, double quotes keep everything but the backslash escapes of $ ` " \ and newline, a backslash outside quotes keeps the next character, quotes are removed

func SplitCommandLine

func SplitCommandLine(s string) ([]string, error)

Words of a command line written for this host: Split on POSIX systems, SplitRaw on Windows where backslashes separate path elements

func SplitComments

func SplitComments(s string) ([]string, error)

Words of s split as Split does, a # where a word would start beginning a comment that runs to the end of its line

func SplitOperators

func SplitOperators(s string) ([]string, error)

Words and shell operators of s split as SplitComments does, unquoted ( ) ; < > | & cut into the longest operators such as && || ;; >> |& and given as tokens of their own

func SplitRaw

func SplitRaw(s string) ([]string, error)

Words of s split at blanks with single or double quotes grouping and removed, every backslash kept as typed the way Windows command lines and paths use them

Types

This section is empty.

Jump to

Keyboard shortcuts

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