shsprintf

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 8 modules, 5 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 shsprintf is a drop-in-replacement for using sprintf to produce shell scripts, that adds automatic detection for command / argument injection.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidShTemplate error = errors.New("Invalid Shell Template")

ErrInvalidShTemplate indicates the requested template is not a valid script

View Source
var ErrShInjection error = errors.New("Shell Injection Detected")

ErrShInjection indicates the inputs resulted in shell injection.

Functions

func EscapeDefaultContext

func EscapeDefaultContext(in string) string

EscapeDefaultContext escapes special characters in a context where there is no existing quoting, such as --arg=%s

func MustSprintf

func MustSprintf(format string, a ...any) string

MustSprintf is a wrapper to Sprintf that panics upon error.

func Sprintf

func Sprintf(format string, a ...any) (string, error)

Sprintf is a fmt.Sprintf replacement specific for generating bash scripts, with protection against any string substitution from escaping its context, or from injecting new flag arguments.

func SprintfLang

func SprintfLang(format string, lang syntax.LangVariant, a ...any) (string, error)

SprintfLang is a fmt.Sprintf replacement specific for generating shell scripts, with protection against any string substitution from escaping its context, or from injecting new flag arguments.

Types

This section is empty.

Jump to

Keyboard shortcuts

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