shfmt

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(src string) (string, error)

Format pretty-prints a shell program. It normalizes the input to a single line (via ImplodeSh), inserts line breaks at configured boundaries (via ExplodeSh), then re-indents and normalizes the result. && and || are moved to the next line with backslash continuation. When MaxWidth > 0 and the single-line command fits within it, binary operator breaks are skipped; clause breaks still apply.

Types

type Config

type Config struct {
	BinCmd   bool // break at pipes, &&, ||
	Clause   bool // break for/while/if/case clauses
	MaxWidth int  // max line width; binary operators are only broken when the single-line command exceeds this (0 = always break)
}

Config controls which structural boundaries get line breaks.

var Cfg Config

Cfg is the active configuration.

Jump to

Keyboard shortcuts

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