GNU bug report logs - #16782
date: reject invalid %[X] format characters

Previous Next

Package: coreutils;

Reported by: fuz <at> fuz.su

Date: Mon, 17 Feb 2014 17:46:02 UTC

Severity: wishlist

To reply to this bug, email your comments to 16782 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#16782; Package coreutils. (Mon, 17 Feb 2014 17:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to fuz <at> fuz.su:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 17 Feb 2014 17:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: fuz <at> fuz.su
To: bug-coreutils <at> gnu.org
Subject: Insensitive behavior in date when given invalid fomatting string
Date: Mon, 17 Feb 2014 18:42:01 +0100
[Message part 1 (text/plain, inline)]
Consider the following set of date invocations:

    $ date --version
    date (GNU coreutils) 8.20
    Copyright (C) 2012 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.

    Written by David MacKenzie.
    $ date +%05
    00%05
    $ date +%Y%#05
    20140%#05
    $ date +x%7
    x     %7
    $ date "+%7 xyz"
        %7 xyz
    $ date "+%7q xyz"
        %7q xyz

GNU date behaves strangely when given an invalid formatting string. GNU date
does not inform the user about the invalid formatting string; instead it outputs
padding as if the flags and field-width, flags and E/O modifier were the whole
formatting string, then the unchanged formatting string. This behavior is not
incorrect as of POSIX.1-2008, as the standard does not specify the behavior of
date in case of an invalid format string, yet it is highly unexpected and weird.

I suggest changing GNU date to output incorrect parts of a formatting string
as-is (as done by the date shipped with Solaris) and possibly exiting with a
non-zero exit status.

Yours sincerely,
Robert Clausecker
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#16782; Package coreutils. (Sun, 21 Oct 2018 21:32:02 GMT) Full text and rfc822 format available.

Message #8 received at 16782 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: 16782 <at> debbugs.gnu.org
Subject: Re: bug#16782: Insensitive behavior in date when given invalid
 fomatting string
Date: Sun, 21 Oct 2018 15:31:37 -0600
severity 16782 wishlist
retitle 16782 date: reject invalid %[X] format characters
stop

(triaging old bugs)

Hello,

On 17/02/14 10:42 AM, fuz <at> fuz.su wrote:
> Consider the following set of date invocations:
> 
>      $ date +%05
>      00%05
>      $ date +%Y%#05
>      20140%#05
>      $ date +x%7
>      x     %7
>      $ date "+%7 xyz"
>          %7 xyz
>      $ date "+%7q xyz"
>          %7q xyz
> 
> GNU date behaves strangely when given an invalid formatting string. GNU date
> does not inform the user about the invalid formatting string; instead it outputs
> padding as if the flags and field-width

It seems your message was never replied to. Sorry about that.

Indeed, this would be a nice improvement, contrast:

  $ printf "+%7 xyz"
  -bash: printf: ` ': invalid format character

  $ /src/printf "+%7 xyz"
  +./src/printf: %7 : invalid conversion specification

  $ ./src/printf "+%7q xyz"
  +./src/printf: %7q: invalid conversion specification

Marking this as a "wishlist" item.

-assaf





Severity set to 'wishlist' from 'normal' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 21 Oct 2018 21:32:02 GMT) Full text and rfc822 format available.

Changed bug title to 'date: reject invalid %[X] format characters' from 'Insensitive behavior in date when given invalid fomatting string' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 21 Oct 2018 21:32:02 GMT) Full text and rfc822 format available.

This bug report was last modified 5 years and 187 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.