Next: The printf approach, Previous: Three approaches for Shell Scripts, Up: sh - Shell Script [Contents][Index]
gettext.sh approach ¶ This approach uses shell functions defined in the gettext.sh file.
Here’s an example that references a shell variable pid:
eval_gettext "Running as process number \$pid."; echo
A ready-to-use example is available in the hello-1.sh file
in the examples/hello-sh directory.
gettext.sh ¶ gettext.sh, contained in the run-time package of GNU gettext,
provides the following:
$echoThe variable echo is set to a command that outputs its first argument
and a newline, without interpreting backslashes in the argument string.
eval_gettexteval_ngettexteval_pgettexteval_npgettextAdvantages:
Drawbacks:
eval_gettext et al. functions
must not start nor end with a newline.
This means, in order to add a newline after a message,
you need to add an explicit invocation of echo.
eval_gettext et al. functions
uses a pipe and a subshell.
This is slower than the printf_gettext approach.
Next: The printf approach, Previous: Three approaches for Shell Scripts, Up: sh - Shell Script [Contents][Index]