shellwords

package
v0.75.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package shellwords implements a small, dependency-free, quote-aware tokenizer for a single command line, shared by the Paste-source command detector (internal/configimport, FR-064) and the catalog install-command splitter (internal/registries, data-model §9 CatalogInstall). It is deliberately independent of internal/oauth's spawnargv helpers, which parse argv already split by the shell for a different purpose (OAuth browser launch); duplicating a ~30-line tokenizer here is cheaper than coupling the two packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Split

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

Split tokenizes s the way a POSIX shell would for a single command line: whitespace-separated words, with '...' and "..." both grouping their contents into one word (no expansion of any kind — this only ever feeds a preview, never a shell).

Backslash escaping follows POSIX with one deliberate softening so that pasted Windows paths survive: inside single quotes a backslash is always literal; inside double quotes it escapes only ", \, $ and `; outside quotes it escapes only whitespace, ' and " (NOT another backslash), so C:\Users\me\node.exe and \\host\share stay intact. A backslash before any other character, or at the very end of the input, is kept literally.

Returns an error if a quote is left unterminated. An empty or whitespace-only input returns (nil, nil).

Types

This section is empty.

Jump to

Keyboard shortcuts

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