X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C20853858D32
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1711993606;
	bh=WeQkVxL+ba+PB9NDaRxwnU7znPw0Jy1haoeApYE894k=;
	h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:
	 From;
	b=HSS3Xf4vn/3ekyzxYowDr/d46qwzJLwGHvu+w0crHi2V5/4r1XoSUVb1yTadBXjsZ
	 xjE0EPhCbYi/nCj68ucdixp9gUSjy1ptGGnAubKAj4Od5bhgupFzVIudDPLjqIx08n
	 vk3w702ndkuLu4IYkDUtb/jTptiyKm4Yg2QTiztc=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C55423858C50
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C55423858C50
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711993582; cv=none;
 b=MFFHaCToUjoEhkaPfhuTezT82MKyfSAPSiu3Jc0i58IEhlyxTgjXvsxAkn8i/NSnHTbgx8+nGpKkQM39VQuIsy/A6MD29RO4H6bd4ahIvmOlG6hwmFtBbCdwws6Ku49XuloaTTTRMSshQf+TXqx21nNDsJlUItRW1xvT0/HHJ8Y=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
 t=1711993582; c=relaxed/simple;
 bh=lXWfYRiyzQy6g8Jmybe2N3LiCoGXJVdfQ0yaPQ7+8DU=;
 h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To;
 b=LxMKFjOEa8CLnRGs0YE15Naj1vahzCsHJVkaWHBajAi0py63gjiAidgfiFQuhrCNz2DQs44xNUo134f8cLkDVZoKjmogAXJwfCD7pae6zu9JeMcFTQKbS013LXxBkLCM/QJimCkwxAoIboLbQaw90TZ1qaA6K/zBkqs+VBk5FMU=
ARC-Authentication-Results: i=1; server2.sourceware.org
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1711993580; x=1712598380;
 h=to:subject:message-id:date:from:in-reply-to:references:mime-version
 :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=tjGHRRfzr0AnUsuHM3DOy9gNmEwOwJdul0I/nwjAwCY=;
 b=M7cit9QsDaCzaXI44Lld9VybDKVKikKxCFYEAEas0Owk+PRk/yNS+UlkAyUJgiUw1+
 3VFL7BOVAVX4McWPO63HHjJ8lI7bm8t0VcQdfCG287Ey66lqT3pNPzepgG1Xe/qiuO8U
 skD9xbxmB4Hdpssnfz0wS+OhWTVMk8KNhELrfXFcazJzx2agRtXMIoozFb1e/+l6++/G
 ZEK42wo2QKQOzKjvM/HHJlz8bUkwCz5eZ2GzqFTfmFnzfCRqJ6joyetituDiFfWedCTm
 Vd/FFGusK/qmWj5racS4nkchTW4/hDC2wwtYJpQEpCzM6vmEQT3oi351eI2FsKiu1vYq
 /bwA==
X-Forwarded-Encrypted: i=1;
 AJvYcCViMlCaQASDgBekQ3ZZ8NcsljXEIiO/P7j/yWMShzqKy0hXCmm/l75oI+e/IIUfcaZ6ygvb39QlMmGh3KTWSt0OhA==
X-Gm-Message-State: AOJu0Yzpf25dioZ3Zt+vlBC2e+CDFoLuyUb/d15BUe0eC6P8x2k4qZmY
 z/kLhjVmt8YX7qnu5O+CAfwDOg4xLyJBvmS8ouFfhFfH0wM3QLLEVwiUiqsInwIMHCa46uQ45UT
 WmR4I0ZguCQmG6xMvln5fy8BM2dTdCotkUYax
X-Google-Smtp-Source: AGHT+IEQiNkvdf2zLRcDBVI5+JKMyHH4xPVSP8Tct7/3QFIDkliWy2QWRoP3RVl746N9v17qu7HcaUdzfazM1hd8UZw=
X-Received: by 2002:a05:6870:51ce:b0:22e:514f:cd11 with SMTP id
 b14-20020a05687051ce00b0022e514fcd11mr2386667oaj.1.1711993580026; Mon, 01 Apr
 2024 10:46:20 -0700 (PDT)
MIME-Version: 1.0
References: <AS4P194MB18164A9A59EFC2E3C8439FF4CF3F2@AS4P194MB1816.EURP194.PROD.OUTLOOK.COM>
In-Reply-To: <AS4P194MB18164A9A59EFC2E3C8439FF4CF3F2@AS4P194MB1816.EURP194.PROD.OUTLOOK.COM>
Date: Mon, 1 Apr 2024 18:45:43 +0100
Message-ID: <CA+kUOakHx+e7CRewy9c_HkuePZDmDUYzkDThqvg8ieCH6YYgwA@mail.gmail.com>
Subject: Re: bash builtin printf date format problem
To: Chris Elvidge <celvidge@outlook.com>,
        "Cygwin (cygwin@cygwin.com)" <cygwin@cygwin.com>
X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIM_SIGNED,
 DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_NONE,
 SPF_HELO_NONE, SPF_PASS, TXREP,
 URIBL_SBL_A autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on
 server2.sourceware.org
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Adam Dinwoodie via Cygwin <cygwin@cygwin.com>
Reply-To: Adam Dinwoodie <adam@dinwoodie.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@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

-- 
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
