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
Description: Digital signature
