gsh

package module
v0.0.0-...-6c43801 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 13 Imported by: 0

README

gsh

this library is NOT threadsafe

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Env is the shell environment.
	Env = syscall.Environ()

	// Standard file descriptors.
	Stdin  = fsys.Stdin()
	Stdout = fsys.Stdout()
	Stderr = fsys.Stderr()

	// Shell is the current user's shell binary.
	Shell = func() string {
		for _, kv := range Env {
			if strings.HasPrefix(kv, "SHELL=") {
				return kv[6:]
			}
		}
		panic("$SHELL not set")
	}()

	// Pwd is the current directory.
	Pwd = func() string {
		for _, kv := range Env {
			if strings.HasPrefix(kv, "PWD=") {
				return kv[4:]
			}
		}
		panic("$PWD not set")
	}()

	// Err stores last returned error.
	Err error
)

Functions

func Basename

func Basename(path string) string

Basename returns the last element of path

func Cat

func Cat(path string) string

Cat will return contents of given file path.

func Cd

func Cd(path string)

Cd will change to given dir path.

func Dirname

func Dirname(path string) string

Dirname returns all but the last element of path

func Eprint

func Eprint(msg string)

Eprint will print given message string to stderr.

func Eprintf

func Eprintf(format string, args ...any)

Eprintf will print given format string to stderr.

func Exec

func Exec(path string, args ...string) string

Exec ...

func Flags

func Flags(flags ...fflag.Flag) []string

Flags will parse provided flags

func Float

func Float(a string) float64

Float will convert input string to float.

func Glob

func Glob(path string) []string

Glob ...

func Int

func Int(a string) int64

Int will convert input string to integer.

func IsAbs

func IsAbs(path string) bool

IsAbs returns whether path is absolute.

func IsRel

func IsRel(path string) bool

IsRel returns whether path is relative.

func IterDir

func IterDir(path string, iter func(path string) bool)

IterDir will iterate over the entries contained within dir at path.

func Lstat

func Lstat(path string) *unix.Stat_t

Lstat ...

func Path

func Path(parts ...string) string

Path will return the cleaned, combined series of paths.

func Print

func Print(msg string)

Print will print given message string to stdout.

func Printf

func Printf(format string, args ...any)

Printf will print given format string to stdout.

func ReadDir

func ReadDir(path string) []string

ReadDir will returns the entries contained within dir at path.

func ReadExec

func ReadExec(path string, args ...string) []string

ReadExec ...

func ReadFile

func ReadFile(path string) []string

ReadFile will return the lines contained within file at path.

func Size

func Size(a string) bytesize.Size

Size will convert input string to byte size.

func Stat

func Stat(path string) *unix.Stat_t

Stat ...

func Trim

func Trim(input string) string

Trim will trim all prefixing / suffixing unicode space from input.

Types

This section is empty.

Jump to

Keyboard shortcuts

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