Closed Bug 64217 Opened 24 years ago Closed 23 years ago

make fails when date string contains '

Categories

(NSPR :: NSPR, defect, P2)

4.0.2
All
Linux
defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: tzafrir, Assigned: wtc)

Details

Attachments

(1 file)

I use a hebrew (he_IL) glibc locale. the date string of this locale contains one
' character.

on nsprpub/pr/src/ I get the following error:
/bin/sh: -c: line 1: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 2: syntax error: unexpected end of file

when trying to build the target 
Linux2.2.17pre6_x86_PTH_OPT.OBJ/_pr_bld.h

in the Makefile I see:

$(TINC):
	@$(MAKE_OBJDIR)
	@$(ECHO) '#define _BUILD_STRING "$(SH_DATE)"' > $(TINC)
(etc.)

indeed bash does not accept the syntax:
echo 'foo "'bar"'


A workaround:
run make with a different date format. e.g. (on bash):
LC_TIME=C make


To reproduce: 
have the 'date' command contain exactly one ' character.
e.g.: replace /bin/date with a script that returns `date.orig|sed -e "s/.$/\'/"`

or simply use the he_IL (iw_IL or he on some systems) locale, if it is installed
on your system.
Marking NEW to get someone to look at it.
Status: UNCONFIRMED → NEW
Ever confirmed: true
This is a known problem.  Instead of using 'date',
I'm considering writing a small program that outputs
the current date and time in ISO 8601 notation.
(http://www.cl.cam.ac.uk/~mgk25/iso-time.html)
(http://www.w3.org/TR/1998/NOTE-datetime-19980827)

Here is such a program and a sample output.

gandalf:/u/wtc/time 70% cat time.c
#include <stdio.h>
#include <time.h>

int main()
{
    struct tm *gmt;
    time_t clock;

    clock = time(NULL);
    gmt = gmtime(&clock);
    printf("%04d-%02d-%02dT%02d:%02d:%02dZ\n",
        gmt->tm_year + 1900,
        gmt->tm_mon + 1,
        gmt->tm_mday,
        gmt->tm_hour,
        gmt->tm_min,
        gmt->tm_sec);
    return 0;
}
gandalf:/u/wtc/time 71% cc time.c
gandalf:/u/wtc/time 72% ./a.out
2001-01-13T06:20:34Z
gandalf:/u/wtc/time 73%
Status: NEW → ASSIGNED
Priority: -- → P3
Target Milestone: --- → 4.2
Version: other → 4.0.2
Priority: P3 → P1
Priority: P1 → P2
I checked in my proposed patch on the trunk of NSPR.

Now the version strings in our libraries look like this:
        NSPR 4.2 Beta (debug)  2001-06-23 07:16:16
or
     $Header: NSPR 4.2 Beta (debug)  2001-06-23 07:16:16 $

No time zone is specified, so the time is the local time.
'date' can only print time zone names (such as PDT) but not
time zone offsets (such as -07:00).  If we want language-neutral
time zone info, I could also use UTC (GMT) and say
    date -u "+%Y-%m-%d %TZ"
but I found that most people don't know what the Z in
    2001-06-23 14:16:16Z
stands for.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: