Help us shape the future of Go! Take the 2026 Go Developer Survey

alias

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package alias implements parse-time alias expansion for go-bash. When `shopt expand_aliases` is on, the runtime calls Expand on each parsed *syntax.File before running it; this walks every *syntax.CallExpr and rewrites the first argument when it matches an alias name.

Expansion is intentionally simple — we re-tokenize the alias body by parsing it as a standalone script and extracting the first simple command's Args. Recursive expansion (where an alias body references another alias) is supported via a second pass with a visited-set guard, matching bash's anti-loop semantics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(file *syntax.File, aliases map[string]string)

Expand walks file and rewrites every *syntax.CallExpr whose first argument is a single-literal word matching an entry in aliases. The argument is replaced by the alias body's tokens; any additional arguments are appended after.

aliases may be nil — Expand is a no-op in that case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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