debconf-escape
Escape strings for use in Debconf templates
SYNOPSIS
debconf-escape [string]
DESCRIPTION
debconf-escape is a utility in the debconf package for Debian-based systems. It reads a string from standard input or the command line and outputs it with special characters escaped for safe inclusion as a value in debconf template files. Debconf manages package configuration during installation via dpkg.
Special characters like double quote ("), single quote ('), backslash (\), backtick (`), dollar sign ($), hash (#), newline, carriage return, and tab are escaped to prevent parsing issues. Escapes include:
• \" for "
• \' for '
• \\ for \
• \` for `
• \$ for $
• \# for #
• \n for newline
• \r for carriage return
• \t for tab
This ensures templates parse correctly. Output goes to stdout with no added trailing newline unless present in input. Primarily used by package maintainers scripting config files.
CAVEATS
Performs debconf-specific escaping only; unsuitable for shell or other contexts without adjustment. Test output in actual templates to verify parsing.
EXAMPLES
echo 'hello \nworld' | debconf-escape
hello \\nworld
debconf-escape 'Hi "there\"'
Hi \\"there\\"
TEMPLATE USAGE
Place output within double quotes in templates:
Template: example/package
Value: `debconf-escape "$USER_INPUT"`
HISTORY
Part of debconf package, developed by Joey Hess circa 2000 for Debian's modular config system. Evolved with debconf versions; stable utility for template handling in package maintenance.
SEE ALSO
debconf(7), debconf-communicate(1), debconf-set-selections(1), debconf-get-selections(1), dpkg-reconfigure(8)


