loginenv

package
v0.18.3 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 10 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 loginenv learns the environment of the user's login shell, which the sessions stagent starts begin from: the bridge's (session.spawn, task.create) and the daemon's (schedule runs).

Index

Constants

View Source
const TryTimeout = 5 * time.Second

TryTimeout bounds one try of Capture; rc files that hang (waiting for input, network) must not block session.spawn or a schedule run.

Variables

This section is empty.

Functions

func Capture

func Capture(exe string, within time.Duration) ([]string, error)

Capture returns the environment of the user's login shell, exe being the stagent binary that prints it (`stagent __env`), taking within at most in all.

An SSH exec channel runs the command through a non-login, non-interactive shell, and the daemon runs wherever it was started from, so PATH entries set in ~/.bash_profile, ~/.zprofile or ~/.zshrc (bun, nvm, Homebrew, …) are missing and programs installed there fail with "executable file not found in $PATH". The shell is run as a login, interactive shell first (zsh users keep PATH in .zshrc), then as a login shell only, without a controlling terminal, each try for TryTimeout at most and what is left of within.

func Dump

func Dump() int

Dump is `stagent __env`: print the process environment after envMarker, NUL separated. Capture runs it through the user's login shell to learn the environment their terminal sessions get.

func Get

func Get(env []string, key string) string

Get returns the last value of key in env.

func Key

func Key(k string) string

Key normalizes a variable name for comparison (case-insensitive on Windows).

func Merge

func Merge(current, login []string) []string

Merge starts from the login shell's environment (PATH and exports from profile/rc files) and keeps variables of the process's own environment that the login shell did not set (SSH_*, anything the sshd session added).

Types

This section is empty.

Jump to

Keyboard shortcuts

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