proc

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 4 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 proc holds the state of the process a command runs in, its working directory and environment, read once by the command and passed down, so nothing below reads the process itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	Dir   string
	Wd    string
	WdErr error
	Env   []string
}

State is the working directory and environment a command runs in. Dir is the working directory by the name commands hand down; in the real run it is ".". Wd and WdErr are what the process's working directory lookup returned, once. Env is the environment as "key=value" entries.

func (State) Abs

func (s State) Abs(path string) (string, error)

Abs returns path as an absolute, cleaned path, as filepath.Abs does, joining a relative path to Wd. With no working directory it returns WdErr.

func (State) Environ

func (s State) Environ() []string

Environ returns a copy of the environment the caller may append to.

func (State) Getenv

func (s State) Getenv(key string) string

Getenv returns the value of key, or "" when it is unset.

func (State) Getwd

func (s State) Getwd() (string, error)

Getwd returns the working directory read at the start, or its error.

func (State) Home

func (s State) Home() (string, error)

Home returns the home directory, as os.UserHomeDir does for the process.

func (State) LookupEnv

func (s State) LookupEnv(key string) (string, bool)

LookupEnv returns the value of key and whether it is set. When a key appears twice the last one wins, as it does for a child started with Env.

Jump to

Keyboard shortcuts

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