shell

package
v0.0.0-...-527d38f Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package shell contains functions for quoting arguments to commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuoteUnix

func QuoteUnix(args ...string) string

QuoteUnix takes an array of strings representing individual arguments of a command and returns a space-delimited sequence of double-quoted string literals quoted correctly for any POSIX-compatible shell.

It does not produce pretty output. QuoteUnix("a", "cool", "bear") becomes `"a" "cool" "bear"`, not `a cool bear`. This behavior simplifies the implementaiton, but also bypasses aliases if we are handing our string to a login shell.

QuoteUnix(s) is a valid UTF-8 string if and only if s is a valid UTF-8 string. Proof of this fact is left as an exercise to the reader.

When given a single argument s, QuoteUnix(s) quotes that argument alone.

When given multiple arguments, QuoteUnix(...) produces a space delimited sequence of quoted strings, which is interpreted as a command with arguments by every POSIX-compatible shell.

See https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html for more information.

Types

This section is empty.

Jump to

Keyboard shortcuts

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