Merge remote-tracking branch 'mksh/master'
Conflicts: check.t main.c
This commit is contained in:
commit
df20ee1fff
89
check.t
89
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.703 2015/07/10 19:36:31 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.705 2015/08/13 22:06:19 tg Exp $
|
||||
# -*- mode: sh -*-
|
||||
#-
|
||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
@ -30,7 +30,7 @@
|
||||
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R51 2015/07/10
|
||||
@(#)MIRBSD KSH R51 2015/08/13
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
@ -39,7 +39,7 @@ name: KSH_VERSION
|
||||
category: shell:legacy-no
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)LEGACY KSH R51 2015/07/10
|
||||
@(#)LEGACY KSH R51 2015/08/13
|
||||
description:
|
||||
Check version of legacy shell.
|
||||
stdin:
|
||||
@ -7466,7 +7466,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH:." \command .'
|
||||
source='PATH=$PATH:. \command .'
|
||||
stop='\kill -STOP'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
@ -7488,28 +7488,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH:." \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-1-hartz4-semi
|
||||
description:
|
||||
Check if built-in shell aliases are okay
|
||||
category: os:os2
|
||||
stdin:
|
||||
alias
|
||||
typeset -f
|
||||
expected-stdout:
|
||||
autoload='\typeset -fu'
|
||||
functions='\typeset -f'
|
||||
hash='\builtin alias -t'
|
||||
history='\builtin fc -l'
|
||||
integer='\typeset -i'
|
||||
local='\typeset'
|
||||
login='\exec login'
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH;." \command .'
|
||||
source='PATH=$PATH:. \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-1-os2
|
||||
@ -7530,7 +7509,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH;." \command .'
|
||||
source='PATH=$PATH\;. \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-2b
|
||||
@ -7552,7 +7531,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH:." \command .'
|
||||
source='PATH=$PATH:. \command .'
|
||||
stop='\kill -STOP'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
@ -7575,7 +7554,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH:." \command .'
|
||||
source='PATH=$PATH:. \command .'
|
||||
stop='\kill -STOP'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
@ -7598,7 +7577,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH:." \command .'
|
||||
source='PATH=$PATH:. \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-3b-hartz4
|
||||
@ -7620,51 +7599,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH:." \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-2b-hartz4-semi
|
||||
description:
|
||||
Check if “set -o sh” does not influence built-in aliases
|
||||
category: os:os2
|
||||
arguments: !-o!sh!
|
||||
stdin:
|
||||
alias
|
||||
typeset -f
|
||||
expected-stdout:
|
||||
autoload='\typeset -fu'
|
||||
functions='\typeset -f'
|
||||
hash='\builtin alias -t'
|
||||
history='\builtin fc -l'
|
||||
integer='\typeset -i'
|
||||
local='\typeset'
|
||||
login='\exec login'
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH;." \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-3b-hartz4-semi
|
||||
description:
|
||||
Check if running as sh does not influence built-in aliases
|
||||
category: os:os2
|
||||
stdin:
|
||||
cp "$__progname" sh
|
||||
./sh -c 'alias; typeset -f'
|
||||
rm -f sh
|
||||
expected-stdout:
|
||||
autoload='\typeset -fu'
|
||||
functions='\typeset -f'
|
||||
hash='\builtin alias -t'
|
||||
history='\builtin fc -l'
|
||||
integer='\typeset -i'
|
||||
local='\typeset'
|
||||
login='\exec login'
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH;." \command .'
|
||||
source='PATH=$PATH:. \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-2b-os2
|
||||
@ -7686,7 +7621,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH;." \command .'
|
||||
source='PATH=$PATH\;. \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-3b-os2
|
||||
@ -7708,7 +7643,7 @@ expected-stdout:
|
||||
nameref='\typeset -n'
|
||||
nohup='nohup '
|
||||
r='\builtin fc -e -'
|
||||
source='PATH="$PATH;." \command .'
|
||||
source='PATH=$PATH\;. \command .'
|
||||
type='\builtin whence -v'
|
||||
---
|
||||
name: aliases-cmdline
|
||||
|
14
funcs.c
14
funcs.c
@ -1,5 +1,5 @@
|
||||
/* $OpenBSD: c_ksh.c,v 1.34 2013/12/17 16:37:05 deraadt Exp $ */
|
||||
/* $OpenBSD: c_sh.c,v 1.45 2014/08/27 08:26:04 jmc Exp $ */
|
||||
/* $OpenBSD: c_sh.c,v 1.46 2015/07/20 20:46:24 guenther Exp $ */
|
||||
/* $OpenBSD: c_test.c,v 1.18 2009/03/01 20:11:06 otto Exp $ */
|
||||
/* $OpenBSD: c_ulimit.c,v 1.19 2013/11/28 10:33:37 sobrado Exp $ */
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.280 2015/07/09 20:52:39 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.282 2015/08/13 21:38:17 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
/*
|
||||
@ -1374,7 +1374,7 @@ c_kill(const char **wp)
|
||||
for (; wp[i]; i++) {
|
||||
if (!bi_getn(wp[i], &n))
|
||||
return (1);
|
||||
#if (ksh_NSIG < 128)
|
||||
#if (ksh_NSIG <= 128)
|
||||
if (n > 128 && n < 128 + ksh_NSIG)
|
||||
n -= 128;
|
||||
#endif
|
||||
@ -1385,7 +1385,7 @@ c_kill(const char **wp)
|
||||
}
|
||||
} else {
|
||||
ssize_t w, mess_cols = 0, mess_octs = 0;
|
||||
int j = ksh_NSIG;
|
||||
int j = ksh_NSIG - 1;
|
||||
struct kill_info ki = { 0, 0 };
|
||||
|
||||
do {
|
||||
@ -2293,7 +2293,7 @@ int
|
||||
c_trap(const char **wp)
|
||||
{
|
||||
Trap *p = sigtraps;
|
||||
int i = ksh_NSIG + 1;
|
||||
int i = ksh_NSIG;
|
||||
const char *s;
|
||||
|
||||
if (ksh_getopt(wp, &builtin_opt, null) == '?')
|
||||
@ -2308,7 +2308,7 @@ c_trap(const char **wp)
|
||||
shprintf(" %s\n", p->name);
|
||||
}
|
||||
++p;
|
||||
} while (--i);
|
||||
} while (i--);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -2542,7 +2542,7 @@ p_time(struct shf *shf, bool posix, long tv_sec, int tv_usec, int width,
|
||||
shf_fprintf(shf, "%s%*ld.%02d%s", prefix, width,
|
||||
tv_sec, tv_usec, suffix);
|
||||
else
|
||||
shf_fprintf(shf, "%s%*ldm%d.%02ds%s", prefix, width,
|
||||
shf_fprintf(shf, "%s%*ldm%02d.%02ds%s", prefix, width,
|
||||
tv_sec / 60, (int)(tv_sec % 60), tv_usec, suffix);
|
||||
}
|
||||
|
||||
|
57
jobs.c
57
jobs.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.112 2015/04/19 14:40:09 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.113 2015/08/13 21:38:19 tg Exp $");
|
||||
|
||||
#if HAVE_KILLPG
|
||||
#define mksh_killpg killpg
|
||||
@ -215,11 +215,14 @@ j_init(void)
|
||||
static int
|
||||
proc_errorlevel(Proc *p)
|
||||
{
|
||||
int termsig;
|
||||
|
||||
switch (p->state) {
|
||||
case PEXITED:
|
||||
return (WEXITSTATUS(p->status));
|
||||
return ((WEXITSTATUS(p->status)) & 255);
|
||||
case PSIGNALLED:
|
||||
return (128 + WTERMSIG(p->status));
|
||||
termsig = WTERMSIG(p->status);
|
||||
return ((termsig < 1 || termsig > 127) ? 255 : 128 + termsig);
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
@ -1225,14 +1228,14 @@ j_waitj(Job *j,
|
||||
* even when not monitoring, but this doesn't make sense since
|
||||
* a tty generated ^C goes to the whole process group)
|
||||
*/
|
||||
{
|
||||
int status;
|
||||
if (Flag(FMONITOR) && j->state == PSIGNALLED &&
|
||||
WIFSIGNALED(j->last_proc->status)) {
|
||||
int termsig;
|
||||
|
||||
status = j->last_proc->status;
|
||||
if (Flag(FMONITOR) && j->state == PSIGNALLED &&
|
||||
WIFSIGNALED(status) &&
|
||||
(sigtraps[WTERMSIG(status)].flags & TF_TTY_INTR))
|
||||
trapsig(WTERMSIG(status));
|
||||
if ((termsig = WTERMSIG(j->last_proc->status)) > 0 &&
|
||||
termsig < ksh_NSIG &&
|
||||
(sigtraps[termsig].flags & TF_TTY_INTR))
|
||||
trapsig(termsig);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1531,7 +1534,7 @@ j_print(Job *j, int how, struct shf *shf)
|
||||
Proc *p;
|
||||
int state;
|
||||
int status;
|
||||
int coredumped;
|
||||
bool coredumped;
|
||||
char jobchar = ' ';
|
||||
char buf[64];
|
||||
const char *filler;
|
||||
@ -1555,41 +1558,49 @@ j_print(Job *j, int how, struct shf *shf)
|
||||
jobchar = '-';
|
||||
|
||||
for (p = j->proc_list; p != NULL;) {
|
||||
coredumped = 0;
|
||||
coredumped = false;
|
||||
switch (p->state) {
|
||||
case PRUNNING:
|
||||
memcpy(buf, "Running", 8);
|
||||
break;
|
||||
case PSTOPPED:
|
||||
strlcpy(buf, sigtraps[WSTOPSIG(p->status)].mess,
|
||||
sizeof(buf));
|
||||
case PSTOPPED: {
|
||||
int stopsig = WSTOPSIG(p->status);
|
||||
|
||||
strlcpy(buf, stopsig > 0 && stopsig < ksh_NSIG ?
|
||||
sigtraps[stopsig].mess : "Stopped", sizeof(buf));
|
||||
break;
|
||||
case PEXITED:
|
||||
}
|
||||
case PEXITED: {
|
||||
int exitstatus = (WEXITSTATUS(p->status)) & 255;
|
||||
|
||||
if (how == JP_SHORT)
|
||||
buf[0] = '\0';
|
||||
else if (WEXITSTATUS(p->status) == 0)
|
||||
else if (exitstatus == 0)
|
||||
memcpy(buf, "Done", 5);
|
||||
else
|
||||
shf_snprintf(buf, sizeof(buf), "Done (%d)",
|
||||
WEXITSTATUS(p->status));
|
||||
exitstatus);
|
||||
break;
|
||||
case PSIGNALLED:
|
||||
}
|
||||
case PSIGNALLED: {
|
||||
int termsig = WTERMSIG(p->status);
|
||||
#ifdef WCOREDUMP
|
||||
if (WCOREDUMP(p->status))
|
||||
coredumped = 1;
|
||||
coredumped = true;
|
||||
#endif
|
||||
/*
|
||||
* kludge for not reporting 'normal termination
|
||||
* signals' (i.e. SIGINT, SIGPIPE)
|
||||
*/
|
||||
if (how == JP_SHORT && !coredumped &&
|
||||
(WTERMSIG(p->status) == SIGINT ||
|
||||
WTERMSIG(p->status) == SIGPIPE)) {
|
||||
(termsig == SIGINT || termsig == SIGPIPE)) {
|
||||
buf[0] = '\0';
|
||||
} else
|
||||
strlcpy(buf, sigtraps[WTERMSIG(p->status)].mess,
|
||||
strlcpy(buf, termsig > 0 && termsig < ksh_NSIG ?
|
||||
sigtraps[termsig].mess : "Signalled",
|
||||
sizeof(buf));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
buf[0] = '\0';
|
||||
}
|
||||
|
4
lex.c
4
lex.c
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: lex.c,v 1.49 2013/12/17 16:37:06 deraadt Exp $ */
|
||||
/* $OpenBSD: lex.c,v 1.50 2015/07/30 14:59:12 zhuk Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.204 2015/07/05 19:53:46 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.205 2015/08/13 21:04:12 tg Exp $");
|
||||
|
||||
/*
|
||||
* states while lexing word
|
||||
|
4
main.c
4
main.c
@ -34,7 +34,7 @@
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.300 2015/07/10 19:36:35 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.301 2015/08/13 22:06:22 tg Exp $");
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -82,7 +82,7 @@ static const char *initcoms[] = {
|
||||
"nameref=\\typeset -n",
|
||||
"nohup=nohup ",
|
||||
"r=\\builtin fc -e -",
|
||||
"source=PATH=\"$PATH" MKSH_PATHSEPS ".\" \\command .",
|
||||
"source=PATH=$PATH" MKSH_PATHSEPE ". \\command .",
|
||||
"login=\\exec login",
|
||||
NULL,
|
||||
/* this is what AT&T ksh seems to track, with the addition of emacs */
|
||||
|
8
mksh.1
8
mksh.1
@ -1,4 +1,4 @@
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.378 2015/07/12 19:09:50 tg Exp $
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.379 2015/08/13 22:09:10 tg Exp $
|
||||
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer 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: July 12 2015 $
|
||||
.Dd $Mdocdate: August 13 2015 $
|
||||
.\"
|
||||
.\" Check which macro package we use, and do other -mdoc setup.
|
||||
.\"
|
||||
@ -1946,8 +1946,8 @@ Assigning 1 to this parameter causes
|
||||
.Ic getopts
|
||||
to process arguments from the beginning the next time it is invoked.
|
||||
.It Ev PATH
|
||||
A colon separated list of directories that are searched when looking for
|
||||
commands and files sourced using the
|
||||
A colon (semicolon on OS/2) separated list of directories that are
|
||||
searched when looking for commands and files sourced using the
|
||||
.Sq \&.
|
||||
command (see below).
|
||||
An empty string resulting from a leading or trailing
|
||||
|
14
sh.h
14
sh.h
@ -172,9 +172,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.739 2015/07/10 19:36:37 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.741 2015/08/13 22:06:23 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R51 2015/07/10"
|
||||
#define MKSH_VERSION "R51 2015/08/13"
|
||||
|
||||
/* arithmetic types: C implementation */
|
||||
#if !HAVE_CAN_INTTYPES
|
||||
@ -337,15 +337,15 @@ struct rusage {
|
||||
/* determine ksh_NSIG: first, use the traditional definitions */
|
||||
#undef ksh_NSIG
|
||||
#if defined(NSIG)
|
||||
#define ksh_NSIG NSIG
|
||||
#define ksh_NSIG (NSIG)
|
||||
#elif defined(_NSIG)
|
||||
#define ksh_NSIG _NSIG
|
||||
#define ksh_NSIG (_NSIG)
|
||||
#elif defined(SIGMAX)
|
||||
#define ksh_NSIG (SIGMAX + 1)
|
||||
#elif defined(_SIGMAX)
|
||||
#define ksh_NSIG (_SIGMAX + 1)
|
||||
#elif defined(NSIG_MAX)
|
||||
#define ksh_NSIG NSIG_MAX
|
||||
#define ksh_NSIG (NSIG_MAX)
|
||||
#else
|
||||
# error Please have your platform define NSIG.
|
||||
#endif
|
||||
@ -367,7 +367,7 @@ struct rusage {
|
||||
#else
|
||||
/* since it’s usable, prefer it */
|
||||
#undef ksh_NSIG
|
||||
#define ksh_NSIG NSIG_MAX
|
||||
#define ksh_NSIG (NSIG_MAX)
|
||||
#endif
|
||||
/* if NSIG_MAX is now still defined, use sysconf(_SC_NSIG) at runtime */
|
||||
#endif
|
||||
@ -387,10 +387,12 @@ struct rusage {
|
||||
#endif
|
||||
|
||||
#ifdef __OS2__
|
||||
#define MKSH_PATHSEPE "\\;"
|
||||
#define MKSH_PATHSEPS ";"
|
||||
#define MKSH_PATHSEPC ';'
|
||||
#define MKSH_UNIXROOT "/@unixroot"
|
||||
#else
|
||||
#define MKSH_PATHSEPE ":"
|
||||
#define MKSH_PATHSEPS ":"
|
||||
#define MKSH_PATHSEPC ':'
|
||||
#define MKSH_UNIXROOT ""
|
||||
|
4
tree.c
4
tree.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.73 2015/04/11 22:03:32 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.74 2015/08/13 20:54:03 tg Exp $");
|
||||
|
||||
#define INDENT 8
|
||||
|
||||
@ -748,6 +748,8 @@ fpFUNCTf(struct shf *shf, int i, bool isksh, const char *k, struct op *v)
|
||||
{
|
||||
if (isksh)
|
||||
fptreef(shf, i, "%s %s %T", Tfunction, k, v);
|
||||
else if (ktsearch(&keywords, k, hash(k)))
|
||||
fptreef(shf, i, "%s %s() %T", Tfunction, k, v);
|
||||
else
|
||||
fptreef(shf, i, "%s() %T", k, v);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user