GNU bug report logs - #15407
bug report

Previous Next

Package: coreutils;

Reported by: João Marques <calaisjoao <at> gmail.com>

Date: Wed, 18 Sep 2013 16:06:02 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: João Marques <calaisjoao <at> gmail.com>
Subject: bug#15407: closed (Re: bug#15407: bug report)
Date: Wed, 18 Sep 2013 16:26:05 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#15407: bug report

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 15407 <at> debbugs.gnu.org.

-- 
15407: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15407
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eric Blake <eblake <at> redhat.com>
To: João Marques <calaisjoao <at> gmail.com>
Cc: 15407-done <at> debbugs.gnu.org
Subject: Re: bug#15407: bug report
Date: Wed, 18 Sep 2013 10:25:36 -0600
[Message part 3 (text/plain, inline)]
tag 15407 notabug
thanks

On 09/18/2013 07:07 AM, João Marques wrote:
> Hi good afternoon
> 
> Yesterday i was reading the manual (man date) of the date command and I
> think that the option + and ' isn't refer on it
> 
> so i was trying to make this command on a script:
> 
>  $(date +'%Y-%m-%d '%H:%M:%S')

As written, that's not a valid command, because it has unbalanced
quotes.  ' is not an option character seen by date, but a quoting
metacharacter consumed by the shell.  You may want to read a good manual
on shell quoting; but as a short tutorial, all of the following are
equivalent:

date +%y-%m-%d\ %H:%M:%S
date '+%y-%m-%d %H:%M:%S'
date '+'"%y-%m-%d"' '"%H:%M:%S"

and so on.  To see what the shell actually did with your quote
characters, use echo (and since the output of all three of these
commands is identical, you can understand why I claim that ' is not a
format character recognized by date):

echo date +%y-%m-%d\ %H:%M:%S
echo date '+%y-%m-%d %H:%M:%S'
echo date '+'"%y-%m-%d"' '"%H:%M:%S"

Why some people insist on using '' around most of the FORMAT argument,
but not the leading + portion (that is, why you see +'%y...' instead of
'+%y...' in examples), is beyond me, but it is perfectly valid shell
quoting either way.

> 
> maybe I'm wrong but if not, it was nice to include this information an some
> examples on the  manual
> so that anyone could make it more easily.

Meanwhile, the '+' option IS documented, in both the man and info pages.
 The man page starts out with:

SYNOPSIS
       date [OPTION]... [+FORMAT]
       date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

See, right there, the leading '+' is what designates a FORMAT argument.
 Failing to use a leading '+' is what tells date to interpret its
argument as MMDDhhmm instead of FORMAT.

Therefore, I'm closing this as not a bug, although you should feel free
to reply with any further questions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]
[Message part 5 (message/rfc822, inline)]
From: João Marques <calaisjoao <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: bug report
Date: Wed, 18 Sep 2013 14:07:22 +0100
[Message part 6 (text/plain, inline)]
Hi good afternoon

Yesterday i was reading the manual (man date) of the date command and I
think that the option + and ' isn't refer on it

so i was trying to make this command on a script:

 $(date +'%Y-%m-%d '%H:%M:%S')

maybe I'm wrong but if not, it was nice to include this information an some
examples on the  manual
so that anyone could make it more easily.

Best regards
João Marques
[Message part 7 (text/html, inline)]

This bug report was last modified 11 years and 248 days ago.

Previous Next


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