LinuxCommandLibrary

git-sh-i18n--envsubst

Substitute variables in git configuration files

SYNOPSIS

git-sh-i18n--envsubst [-u] [-v] [--] [file ...]

PARAMETERS

-u
    Die with error on unknown or unset variables

-v
    Enable verbose output, logging substitutions

file
    Input file(s) to process; defaults to stdin if omitted; stdout if no files

DESCRIPTION

git-sh-i18n--envsubst is an internal Git utility for performing environment variable substitution in shell scripts during internationalization (i18n) processing. It enables dynamic content, such as script names ($0) or arguments ($1, etc.), to be embedded in translatable strings without interfering with gettext mechanisms.

Typically invoked by Git's own shell scripts (e.g., via eval_gettext), it reads input from standard input or specified files line-by-line. It identifies lines containing i18n functions like eval_gettext, eval_gettextln, or n_ variants, extracts double-quoted strings within them, and substitutes escaped variables (e.g., \$0) with their actual values from the environment. The modified strings are then suitable for translation tools.

This prevents translation systems from seeing literal $var as translatable text while preserving runtime expansion. Output is written to standard output or replaces input files if specified. Primarily used in Git's build and runtime i18n workflow, it ensures portable, localized error messages and prompts across scripts.

CAVEATS

Internal Git tool not intended for direct user use; behavior may change across Git versions. Requires Perl. Only substitutes \${0-9} in i18n contexts; ignores other $var.

EXAMPLE USAGE

echo 'eval_gettext "Clone \\$0"' | git-sh-i18n--envsubst
Output: eval_gettext "Clone git-clone" (assuming $0=git-clone)

HISTORY

Introduced in Git v1.7.10 (2010) as part of shell script i18n support; evolved with Git's translation framework to handle dynamic strings in scripts like git-clone.sh.

SEE ALSO

Copied to clipboard