* remove redundancy

* integrate compat.h, version.h into sh.h (dependency trick didn't work anyway)
* mention #ksh in mksh(1) since the founder (twkm) said it's on topic too
  (don't remove mention of #mksh despite it's usually empty because of control)
This commit is contained in:
tg 2006-08-22 22:49:38 +00:00
parent 93ab969fdc
commit 4fac7ec24b
8 changed files with 96 additions and 103 deletions

View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.58 2006/08/18 13:41:09 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.59 2006/08/22 22:49:33 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -3856,5 +3856,5 @@ category: pdksh
stdin:
echo $KSH_VERSION
expected-stdout:
@(#)MIRBSD KSH R28 2006/08/18
@(#)MIRBSD KSH R28 2006/08/22
---

View File

@ -1,70 +0,0 @@
#define MKSH_COMPAT_H_ID "$MirOS: src/bin/mksh/compat.h,v 1.4 2006/08/22 22:16:04 tg Exp $"
#ifdef NEED_COMPAT
/* Part I: extra headers */
#if defined(__sun__) || defined(__INTERIX)
#include <sys/mkdev.h>
#endif
#if !defined(__OpenBSD__) && !defined(__CYGWIN__)
#include <ulimit.h>
#endif
#if defined(__sun__) || defined(__gnu_linux__)
#include <values.h>
#endif
/* Part II: extra macros */
#ifndef timeradd
#define timeradd(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
if ((vvp)->tv_usec >= 1000000) { \
(vvp)->tv_sec++; \
(vvp)->tv_usec -= 1000000; \
} \
} while (0)
#endif
#ifndef timersub
#define timersub(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
if ((vvp)->tv_usec < 0) { \
(vvp)->tv_sec--; \
(vvp)->tv_usec += 1000000; \
} \
} while (0)
#endif
#ifndef S_ISTXT
#define S_ISTXT 0001000
#endif
/* Part III: OS-dependent additions */
#if defined(__gnu_linux__)
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
#endif
#if defined(__sun__)
size_t confstr(int, char *, size_t);
#endif
#if defined(__gnu_linux__) || defined(__sun__) || defined(__CYGWIN__)
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
mode_t getmode(const void *, mode_t);
void *setmode(const char *);
#endif
#ifdef __INTERIX
#define makedev(x,y) mkdev((x),(y))
extern int __cdecl seteuid(uid_t);
extern int __cdecl setegid(gid_t);
#endif
#endif

8
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.36 2006/08/08 20:17:20 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.37 2006/08/22 22:49:34 tg Exp $");
/* tty driver characters we are interested in */
typedef struct {
@ -2674,7 +2674,7 @@ x_version(int c __attribute__((unused)))
char *o_xbuf = xbuf, *o_xend = xend;
char *o_xbp = xbp, *o_xep = xep, *o_xcp = xcp;
int lim = x_lastcp() - xbp;
char *v = strdup(MKSH_VERSION + 4);
char *v = strdup(KSH_VERSION);
int vlen;
xbuf = xbp = xcp = v;
@ -3164,8 +3164,8 @@ vi_hook(int ch)
save_cbuf();
es->cursor = 0;
es->linelen = 0;
putbuf(MKSH_VERSION + 4,
strlen(MKSH_VERSION + 4), 0);
putbuf(KSH_VERSION,
strlen(KSH_VERSION), 0);
refresh(0);
}
}

10
main.c
View File

@ -3,22 +3,22 @@
/* $OpenBSD: io.c,v 1.22 2006/03/17 16:30:13 millert Exp $ */
/* $OpenBSD: table.c,v 1.12 2005/12/11 20:31:21 otto Exp $ */
#define EXTERN /* define EXTERNs in sh.h */
#define EXTERN
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.46 2006/08/18 18:48:25 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.47 2006/08/22 22:49:35 tg Exp $");
extern char **environ;
static void reclaim(void);
static void remove_temps(struct temp * tp);
static void remove_temps(struct temp *);
static const char initifs[] = "IFS= \t\n";
static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }";
static const char *initcoms[] = {
"typeset", "-r", "KSH_VERSION", NULL,
"typeset", "-r", initvsn, NULL,
"typeset", "-x", "SHELL", "PATH", "HOME", NULL,
"typeset", "-i", "PPID", "OPTIND=1", NULL,
"eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
@ -191,8 +191,6 @@ main(int argc, char *argv[])
srand((*((long *)kshname)) ^ ((long)time(NULL) * kshpid * ppid));
#endif
setint(global("PPID"), (long)ppid);
/* setstr can't fail here */
setstr(global("KSH_VERSION"), MKSH_VERSION, KSH_RETURN_ERROR);
/* execute initialisation statements */
for (wp = (char **)initcoms; *wp != NULL; wp++) {

5
misc.c
View File

@ -3,8 +3,8 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.14 2006/08/22 22:16:04 tg Exp $"
"\t" MKSH_SH_H_ID "\t" MKSH_COMPAT_H_ID);
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.15 2006/08/22 22:49:36 tg Exp $\t"
MKSH_SH_H_ID);
short chtypes[UCHAR_MAX+1]; /* type bits for unsigned char */
@ -12,7 +12,6 @@ static int do_gmatch(const unsigned char *, const unsigned char *,
const unsigned char *, const unsigned char *);
static const unsigned char *cclass(const unsigned char *, int);
static int parse_T(char *);
static char *do_phys_path(XString *, char *, const char *);
/*

26
mksh.1
View File

@ -1,8 +1,8 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.56 2006/08/14 20:41:21 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.57 2006/08/22 22:49:36 tg Exp $
.\" $OpenBSD: ksh.1,v 1.116 2006/07/26 10:13:25 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\"
.Dd August 14, 2006
.Dd August 22, 2006
.Dt MKSH 1
.Os MirBSD
.Sh NAME
@ -5301,25 +5301,23 @@ yet.
.Pp
Please report bugs in
.Nm
or this manual page to the MirOS Project discussion mailing list at
to the
.Aq miros-discuss@mirbsd.org
or in the
mailing list or in the
.Li \&#mksh
channel on the OPN IRC network at
.Pa irc.freenode.net
.Pq port 6667 .
or
.Li \&#ksh
IRC channel at
.Pa irc.freenode.net .
.Pp
By the way, the most frequently reported bug is:
.Bd -literal -offset indent
$ print hi \*(Ba read a; print $a # Does not show hi
.Ed
.Pp
The
.Nm pdksh
author is aware of this and there is no need to report it.
This does not work because the last command of a pipe sequence
is run in a subshell.
In
.Nm "" ,
this is a feature which can be depended on by scripts.
is executed in a subshell.
This is a
.Nm
feature which can be depended on by scripts.
Use co-routines to work around if necessary and possible.

75
sh.h
View File

@ -8,7 +8,8 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.38 2006/08/22 22:22:07 tg Exp $"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.39 2006/08/22 22:49:37 tg Exp $"
#define MKSH_VERSION "R28 2006/08/22"
#include <sys/param.h>
@ -44,7 +45,72 @@
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include "compat.h"
#ifdef NEED_COMPAT
/* extra headers */
#if defined(__sun__) || defined(__INTERIX)
#include <sys/mkdev.h>
#endif
#if !defined(__OpenBSD__) && !defined(__CYGWIN__)
#include <ulimit.h>
#endif
#if defined(__sun__) || defined(__gnu_linux__)
#include <values.h>
#endif
/* extra macros */
#ifndef timeradd
#define timeradd(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
if ((vvp)->tv_usec >= 1000000) { \
(vvp)->tv_sec++; \
(vvp)->tv_usec -= 1000000; \
} \
} while (0)
#endif
#ifndef timersub
#define timersub(tvp, uvp, vvp) \
do { \
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
if ((vvp)->tv_usec < 0) { \
(vvp)->tv_sec--; \
(vvp)->tv_usec += 1000000; \
} \
} while (0)
#endif
#ifndef S_ISTXT
#define S_ISTXT 0001000
#endif
/* OS-dependent additions */
#if defined(__gnu_linux__)
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
#endif
#if defined(__sun__)
size_t confstr(int, char *, size_t);
#endif
#if defined(__gnu_linux__) || defined(__sun__) || defined(__CYGWIN__)
#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
mode_t getmode(const void *, mode_t);
void *setmode(const char *);
#endif
#ifdef __INTERIX
#define makedev(x,y) mkdev((x),(y))
extern int __cdecl seteuid(uid_t);
extern int __cdecl setegid(gid_t);
#endif
#endif
/* some useful #defines */
#ifdef EXTERN
@ -54,7 +120,6 @@
# define EXTERN extern
# define EXTERN_DEFINED
#endif
#include "version.h"
#define EXECSHELL "/bin/mksh"
#define EXECSHELL_STR "EXECSHELL"
@ -95,6 +160,10 @@ EXTERN gid_t kshgid; /* real gid of shell */
EXTERN int exstat; /* exit status */
EXTERN int subst_exstat; /* exit status of last $(..)/`..` */
EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
#ifndef EXTERN_DEFINED
static const char initvsn[] = "KSH_VERSION=@(#)MIRBSD KSH " MKSH_VERSION;
#endif
EXTERN const char *KSH_VERSION I__(initvsn + 16);
/*
* Area-based allocation built on malloc/free

View File

@ -1 +0,0 @@
EXTERN const char MKSH_VERSION[] I__("@(#)MIRBSD KSH R28 2006/08/18");