[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: qwerty
From: |
Chet Ramey |
Subject: |
Re: qwerty |
Date: |
Wed, 11 Nov 2009 21:05:49 -0500 |
User-agent: |
Thunderbird 2.0.0.23 (Macintosh/20090812) |
Ken Irving wrote:
>> $ 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...?
When bash detects an integer conversion error, it returns 0. That's not
strictly Posix-conformat, so the next version of bash will return
whatever strtoimax/strtoll/strtol returns, which is supposed to be the
value accumulated up to the point of the error.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
- qwerty, Antonio Macchi, 2009/11/11
- Re: qwerty, Ken Irving, 2009/11/11
- Re: qwerty,
Chet Ramey <=
- Message not available
- Message not available
Message not available