help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Escape Character and NewLine


From: Greg Wooledge
Subject: Re: [Help-bash] Escape Character and NewLine
Date: Tue, 17 Sep 2019 08:55:38 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Sep 17, 2019 at 07:15:23AM +1000, David wrote:
> Wherever a printf command is provided, this is the usual behaviour.
> 
> The bash builtin printf is documented here:
> $ help printf | grep 're-used'
>     The format is re-used as necessary to consume all of the arguments.  If
> 
> For more extensive documentation, try the command
>   man 3 printf
> or read a book on the C language.

To be complete, the original printf() is a function in the C library,
documented in printf(3).  That's the base line.

Then, there's the POSIX printf(1) command, documented at
<https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html>
and sometimes also available as a local man page, e.g. printf(1p) or
similar.

If printf(1) is installed as a local man page, that may indicate some
features or extensions of your local /bin/printf or /usr/bin/printf
command, just in case that differs from POSIX.  However, you will almost
never actually use this command, because...

... printf is also a bash builtin, documented in bash(1) and in "help
printf" inside bash.

"help printf" extends and refers to printf(1) which really means
printf(1p) or the URL given above.  That document, in turn, extends
and refers to printf(3).

Another way to look at it is that bash's printf builtin is
a third-generation tool.  The builtin printf adds features like
"-v varname" so that you can avoid forking every time you want to
emulate sprintf(), and %q so that you can use eval more safely later.
This is on top of the POSIX printf command, which adds features like
implicit looping, %b, and that thing about the leading character being
a single-quote or double-quote.  Which in turn is on top of printf(3),
which offers the basic functionality.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]