On Thu, Nov 12, 2009 at 01:47:52AM +0100, Antonio Macchi wrote:
> $ printf "%s\n" ok -
> ok
> -
>
> why that score in the newline?
Your pattern has one format operator, but there are two arguments,
so the pattern is applied again.

> --------
>
> $ printf "%d %s\n" 1 ok -
> 1 ok
> -bash: printf: -: invalid number
> 0
>
> why getting error here, and not in the previous?
> why "invalid number" ?
> what is that zero?

Again, you have more arguments than operators, so it makes another pass,
and on the second pass tries to format - as a number...  Don't know
about the zero, but I guess %d maybe starts with a default of 0...?

> --------
>
> $ printf "%2s\n" qwerty
> qwerty
>
> strings larger than fixed-width are entire written?

It's not fixed width but minimum width.


> I'm using BASH_VERSION 3.2.39, so please forgive me if this issue are  
> already fixed


There's nothing to fix.  It might help if you provide some markers
in your test patterns so you can see where each argument begins and
ends, e.g.,

    $ printf "(%d) {%s}\n" 1 ok -
    (1) {ok}
    -bash: printf: -: invalid number
    (0) {}
    
Ken

-- 
Ken Irving, fn...@uaf.edu, 907-474-6152
Water and Environmental Research Center
Institute of Northern Engineering
University of Alaska, Fairbanks


Reply via email to