use EPOCHREALTIME as variable, somewhat compatible with “zmodload zsh/datetime”, as ormaaj belatedly found out

This commit is contained in:
tg 2012-11-26 22:49:51 +00:00
parent b58d7b8053
commit 007cf09db6
4 changed files with 9 additions and 9 deletions

4
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h>
#endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.240 2012/11/20 18:07:42 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.241 2012/11/26 22:49:48 tg Exp $");
extern char **environ;
@ -59,7 +59,7 @@ static void x_sigwinch(int);
static const char initifs[] = "IFS= \t\n";
static const char initsubs[] =
"${PS2=> } ${PS3=#? } ${PS4=+ } ${SECONDS=0} ${TMOUT=0} ${MKSH_UNIXTIME=}";
"${PS2=> } ${PS3=#? } ${PS4=+ } ${SECONDS=0} ${TMOUT=0} ${EPOCHREALTIME=}";
static const char *initcoms[] = {
Ttypeset, "-r", initvsn, NULL,

6
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.299 2012/11/20 18:25:12 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.300 2012/11/26 22:49:49 tg Exp $
.\" $OpenBSD: ksh.1,v 1.144 2012/07/08 08:13:20 guenther Exp $
.\"-
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
@ -74,7 +74,7 @@
.\" with -mandoc, it might implement .Mx itself, but we want to
.\" use our own definition. And .Dd must come *first*, always.
.\"
.Dd $Mdocdate: November 20 2012 $
.Dd $Mdocdate: November 26 2012 $
.\"
.\" Check which macro package we use, and do other -mdoc setup.
.\"
@ -1880,7 +1880,7 @@ executed.
.It Ev LINES
Set to the number of lines on the terminal or window.
Always set, defaults to 24.
.It Ev MKSH_UNIXTIME
.It Ev EPOCHREALTIME
Time since the epoch, as returned by
.Xr gettimeofday 2 ,
formatted as decimal

4
var.c
View File

@ -27,7 +27,7 @@
#include <sys/sysctl.h>
#endif
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.158 2012/11/20 18:07:45 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.159 2012/11/26 22:49:50 tg Exp $");
/*-
* Variables
@ -1112,7 +1112,7 @@ getspec(struct tbl *vp)
case V_LINES:
i = x_lins;
break;
case V_MKSH_UNIXTIME: {
case V_EPOCHREALTIME: {
/* 10(%u) + 1(.) + 6 + NUL */
char buf[18];

View File

@ -1,5 +1,5 @@
#if defined(VARSPEC_DEFNS)
__RCSID("$MirOS: src/bin/mksh/var_spec.h,v 1.4 2012/11/20 18:07:45 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/var_spec.h,v 1.5 2012/11/26 22:49:51 tg Exp $");
#define FN(name) /* nothing */
#elif defined(VARSPEC_ENUMS)
#define FN(name) V_##name,
@ -28,7 +28,7 @@ FN(HISTSIZE)
FN(IFS)
FN(LINENO)
FN(LINES)
FN(MKSH_UNIXTIME)
FN(EPOCHREALTIME)
FN(OPTIND)
FN(PATH)
FN(RANDOM)