Re: RFE: printf '%(fmt)T' prints current time by default

2012-12-14 Thread Chet Ramey
  I think the ksh behavior is makes more sense so can we use the current time
  as the default?
  
  -Clark
 
 I agree that a null or empty argument as equivalent to -1 is a better 
 default. 
 0 is identical to the current behavior for empty/unset, so no functionality 
 is lost.

That's not unreasonable.  The current default is what Posix specifies for
printf:

Any extra 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. 

 Additionally, an empty format in ksh is equivalent to the date(1) default for 
 the current locale. So, LC_TIME=C; [[ $(printf '%()T') == $(date) ]] is 
 true.

Bash uses the strftime '%X' conversion, which is described as the
locale's appropriate time representation.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: RFE: printf '%(fmt)T' prints current time by default

2012-12-14 Thread Dan Douglas
On Friday, December 14, 2012 09:57:11 AM Chet Ramey wrote:
   I think the ksh behavior is makes more sense so can we use the current 
   time
   as the default?
   
   -Clark
  
  I agree that a null or empty argument as equivalent to -1 is a better 
  default. 
  0 is identical to the current behavior for empty/unset, so no 
  functionality 
  is lost.
 
 That's not unreasonable.  The current default is what Posix specifies for
 printf:
 
 Any extra 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. 

Ooh ok... hrm I didn't consider it's actually consistent with everything else 
this way. 
-- 
Dan Douglas



Re: RFE: printf '%(fmt)T' prints current time by default

2012-12-14 Thread Chet Ramey
On 12/14/12 12:03 PM, Dan Douglas wrote:
 On Friday, December 14, 2012 09:57:11 AM Chet Ramey wrote:
 I think the ksh behavior is makes more sense so can we use the current time
 as the default?

 -Clark

 I agree that a null or empty argument as equivalent to -1 is a better 
 default. 
 0 is identical to the current behavior for empty/unset, so no 
 functionality 
 is lost.

 That's not unreasonable.  The current default is what Posix specifies for
 printf:

 Any extra 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. 
 
 Ooh ok... hrm I didn't consider it's actually consistent with everything else 
 this way. 

I'm not saying I can't change the %T default -- I probably will, and it
will be documented as an exception in the man page.  The above is the
explanation for the status quo.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/