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 16:31:19 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Tue, Sep 17, 2019 at 05:15:53PM -0300, Fernando Basso wrote:
> According to the POSIX spec on `printf',
> 
> https://pubs.opengroup.org/onlinepubs/9699919799/utilities/printf.html
> 
> the "format" shall be used as the format string as described in the File
> Format Notation docs:

You omitted the four words "with the following exceptions".  They're
really important words.

Under that are 11 numbered exceptions.  Number 9 says:

  The format operand shall be reused as often as necessary to satisfy the
  argument operands. Any extra b, c, or s conversion specifiers shall
  be evaluated as if a null string argument were supplied; other extra
  conversion specifications shall be evaluated as if a zero argument were
  supplied. If the format operand contains no conversion specifications
  and argument operands are present, the results are unspecified.

This overrides the wording in "File Format Notation" which describes the
library call.

> Is that the direct opposite of Bash's `printf'? `help printf':
> 
> ""
> The format is re-used as necessary to consume all of the
> arguments. If there are fewer arguments than the format
> requires, extra format specifications behave as if a zero
> value or null string, as appropriate, had been supplied.
> ""

Looks like bash copied this wording almost verbatim from POSIX.

To repeat what I said before, more concisely:

bash's printf extends printf(1)
printf(1) extends printf(3)



reply via email to

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