usershell

package
v2.36.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: AGPL-3.0 Imports: 5 Imported by: 1 module, 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

This section is empty.

Functions

func ResolveWorkingDirectory added in v2.35.0

func ResolveWorkingDirectory(fs afero.Fs, ei EnvInfoer, dir string) (string, error)

ResolveWorkingDirectory returns dir when it is non-empty and an existing directory on fs. Otherwise it falls back to the home directory reported by ei. SSH sessions and the process API share this so their working directory resolution cannot drift, and the home fallback goes through the injected EnvInfoer rather than the host directly.

Types

type EnvInfoer added in v2.21.0

type EnvInfoer interface {
	// User returns the current user.
	User() (*user.User, error)
	// Environ returns the environment variables of the current process.
	Environ() []string
	// HomeDir returns the home directory of the current user.
	HomeDir() (string, error)
	// Shell returns the shell of the given user.
	Shell(username string) (string, error)
	// ModifyCommand modifies the command and arguments before execution based on
	// the environment. This is useful for executing a command inside a container.
	// In the default case, the command and arguments are returned unchanged.
	ModifyCommand(name string, args ...string) (string, []string)
}

EnvInfoer encapsulates external information about the environment.

type SystemEnvInfo added in v2.21.0

type SystemEnvInfo struct{}

SystemEnvInfo encapsulates the information about the environment just using the default Go implementations.

func (SystemEnvInfo) Environ added in v2.21.0

func (SystemEnvInfo) Environ() []string

func (SystemEnvInfo) HomeDir added in v2.21.0

func (SystemEnvInfo) HomeDir() (string, error)

func (SystemEnvInfo) ModifyCommand added in v2.21.0

func (SystemEnvInfo) ModifyCommand(name string, args ...string) (string, []string)

func (SystemEnvInfo) Shell added in v2.21.0

func (SystemEnvInfo) Shell(username string) (string, error)

func (SystemEnvInfo) User added in v2.21.0

func (SystemEnvInfo) User() (*user.User, error)

Jump to

Keyboard shortcuts

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