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

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to