shellenv

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 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

Overview

Package shellenv loads the environment of a user's login shell.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JoinCommandLine added in v0.1.0

func JoinCommandLine(args []string) string

JoinCommandLine quotes args so that SplitCommandLine returns them unchanged.

func LookPath

func LookPath(env []string, name string) (string, error)

LookPath finds an executable using the supplied environment's PATH and, on Windows, PATHEXT.

func ParseEnv0

func ParseEnv0(out []byte, marker string) []string

ParseEnv0 parses NUL-separated environment entries after the marker. The marker may be followed by a newline or a NUL separator.

func Resolve

func Resolve(ctx context.Context, timeout time.Duration) ([]string, error)

Resolve loads the login shell environment within timeout. On Windows it returns the process environment.

func SplitCommandLine added in v0.1.0

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

SplitCommandLine splits a command line into arguments using POSIX shell quoting rules: single quotes, double quotes with backslash escapes, and backslash escapes outside quotes. It does not expand variables or globs.

Types

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver loads a shell environment once. Its methods are safe for concurrent use.

func Start

func Start(ctx context.Context, timeout time.Duration) *Resolver

Start begins resolving the shell environment in the background.

func (*Resolver) Env

func (r *Resolver) Env() []string

Env waits for the resolution or its deadline and returns an independent slice. It uses the current process environment if the resolution fails.

func (*Resolver) Err

func (r *Resolver) Err() error

Err returns the resolution error or nil while the resolution is still pending.

func (*Resolver) Ready

func (r *Resolver) Ready() bool

Ready reports whether the background resolution has finished, including on failure.

Jump to

Keyboard shortcuts

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