Skip to content

printf: extra specifiers not evaluated as if 0 supplied #9321

@floam

Description

@floam

printf(1) is supposed to have this property:

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.

Fish doesn't do this, causing this discrepancy:

> ksh -c 'printf "%d %d\n" 1 2 3'
1 2
3 0
> zsh -c 'printf "%d %d\n" 1 2 3'
1 2
3 0
> bash -c 'printf "%d %d\n" 1 2 3'
1 2
3 0
> fish -c 'printf "%d %d\n" 1 2 3'
1 2
3 : Invalid argument

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions