public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* bash builtin printf date format problem
@ 2024-04-01 15:28 Chris Elvidge
  2024-04-01 17:45 ` Adam Dinwoodie
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Elvidge @ 2024-04-01 15:28 UTC (permalink / raw)
  To: cygwin

Using bash builtin printf '%(fmt)T', when fmt contains %-d (or %_d), 
there is no output - should print daynumber with no preceding 0 (or with 
preceding space). Similarly %-e. date +"%B %-d" works OK.

$ uname -a
CYGWIN_NT-10.0-19045 ASUS-X550C-WIN 3.5.1-1.x86_64 2024-02-27 11:54 UTC 
x86_64 Cygwin
$ bash --version
GNU bash, version 5.2.21(1)-release (x86_64-pc-cygwin)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:14 pm BST:/home/celvi
$ printf '%(%B %d)T\n'
April 01
[0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:15 pm BST:/home/celvi
$ printf '%(%B %-d)T\n'

[0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:15 pm BST:/home/celvi
$ printf '%(%B %_d)T\n'

[0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:19 pm BST:/home/celvi
$ printf '%(%B %e)T\n'
April  1
[0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:19 pm BST:/home/celvi
$ printf '%(%B %-e)T\n'

[0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:19 pm BST:/home/celvi

Works properly on Slackware current and LMDE6. Anyone any ideas?


Thanks




-- 

Chris Elvidge

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: bash builtin printf date format problem
  2024-04-01 15:28 bash builtin printf date format problem Chris Elvidge
@ 2024-04-01 17:45 ` Adam Dinwoodie
  0 siblings, 0 replies; 2+ messages in thread
From: Adam Dinwoodie @ 2024-04-01 17:45 UTC (permalink / raw)
  To: Chris Elvidge, Cygwin (cygwin@cygwin.com)

On Mon, 1 Apr 2024 at 16:29, Chris Elvidge via Cygwin wrote:
>
> Using bash builtin printf '%(fmt)T', when fmt contains %-d (or %_d),
> there is no output - should print daynumber with no preceding 0 (or with
> preceding space). Similarly %-e. date +"%B %-d" works OK.
>
> $ uname -a
> CYGWIN_NT-10.0-19045 ASUS-X550C-WIN 3.5.1-1.x86_64 2024-02-27 11:54 UTC
> x86_64 Cygwin
> $ bash --version
> GNU bash, version 5.2.21(1)-release (x86_64-pc-cygwin)
> Copyright (C) 2022 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
>
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
> [0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:14 pm BST:/home/celvi
> $ printf '%(%B %d)T\n'
> April 01
> [0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:15 pm BST:/home/celvi
> $ printf '%(%B %-d)T\n'
>
> [0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:15 pm BST:/home/celvi
> $ printf '%(%B %_d)T\n'
>
> [0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:19 pm BST:/home/celvi
> $ printf '%(%B %e)T\n'
> April  1
> [0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:19 pm BST:/home/celvi
> $ printf '%(%B %-e)T\n'
>
> [0] ASUS-X550C-WIN!celvi:(pty0):Mon 01 Apr 2024 04:19 pm BST:/home/celvi
>
> Works properly on Slackware current and LMDE6. Anyone any ideas?

`%-d` isn't a portable construct, and it's not supported by Cygwin.
Specifically, Bash uses the system strftime function for this
formatting, and while lots of systems use glibc, which provides an
strftime that supports `%-d`, Cygwin uses newlib, which doesn't.

As ever, patches to the code will be gratefully received and
thoughtfully considered; the code for Cygwin's strftime lives at
https://cygwin.com/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/time/strftime.c

HTH!


Adam

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-01 17:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-01 15:28 bash builtin printf date format problem Chris Elvidge
2024-04-01 17:45 ` Adam Dinwoodie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).