shell

package
v2.48.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommandRunner                           = crcos.NewLocalCommandRunner()
	WindowsSubsystemLinuxKernelMetadataFile = "/proc/version"
	ErrUnknownShell                         = errors.New("Error: Unknown shell")
)

Functions

func GenerateUsageHint

func GenerateUsageHint(userShell, cmdLine string) string

func GenerateUsageHintWithComment

func GenerateUsageHintWithComment(userShell, cmdLine string) string

func GetEnvString

func GetEnvString(userShell string, envName string, envValue string) string

func GetPathEnvString

func GetPathEnvString(userShell string, prependedPath string) string

func GetShell

func GetShell(userShell string) (string, error)

func IsWindowsSubsystemLinux added in v2.46.0

func IsWindowsSubsystemLinux() bool

IsWindowsSubsystemLinux detects whether current system is using Windows Subsystem for Linux or not

It checks for these conditions to make sure that current system has WSL installed: - `/proc/version` file is present - `/proc/version` file contents contain keywords `Microsoft` and `WSL`

It above conditions are met, then this method returns `true` otherwise `false`.

Types

type AbstractProcess added in v2.47.0

type AbstractProcess interface {
	Name() (string, error)
	Parent() (AbstractProcess, error)
}

AbstractProcess is an interface created to abstract operations of the gopsutil library It is created so that we can override the behavior while writing unit tests by providing a mock implementation.

type Config

type Config struct {
	Prefix     string
	Delimiter  string
	Suffix     string
	PathSuffix string
}

type RealProcess added in v2.47.0

type RealProcess struct {
	*process.Process
}

RealProcess is a wrapper implementation of AbstractProcess to wrap around the gopsutil library's process.Process object. This implementation is used in production code.

func (*RealProcess) Parent added in v2.47.0

func (p *RealProcess) Parent() (AbstractProcess, error)

Jump to

Keyboard shortcuts

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