shave off another 468 bytes: we’re 300 bytes smaller than BEFORE the
cat builtin was added now… (also removed utf-8 from source files, in favour of just ASCII)
This commit is contained in:
6
check.t
6
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.389 2010/08/28 17:21:41 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.390 2010/08/28 20:22:13 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas 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: 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 $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -2268,7 +2268,7 @@ expected-stdout:
|
|||||||
hi
|
hi
|
||||||
1 echo hi
|
1 echo hi
|
||||||
expected-stderr-pattern:
|
expected-stderr-pattern:
|
||||||
/(.*cannot unlink HISTFILE.*\n)?X*$/
|
/(.*can't unlink HISTFILE.*\n)?X*$/
|
||||||
---
|
---
|
||||||
name: history-e-minus-1
|
name: history-e-minus-1
|
||||||
description:
|
description:
|
||||||
@ -6558,7 +6558,7 @@ stdin:
|
|||||||
expected-stdout:
|
expected-stdout:
|
||||||
===
|
===
|
||||||
mir
|
mir
|
||||||
expected-stderr-pattern: /.*: cannot (create|overwrite) .*/
|
expected-stderr-pattern: /.*: can't (create|overwrite) .*/
|
||||||
---
|
---
|
||||||
name: bashiop-3b
|
name: bashiop-3b
|
||||||
description:
|
description:
|
||||||
|
16
edit.c
16
edit.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.198 2010/08/28 18:50:47 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.199 2010/08/28 20:22:15 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* in later versions we might use libtermcap for this, but since external
|
* in later versions we might use libtermcap for this, but since external
|
||||||
@ -324,7 +324,7 @@ x_file_glob(int flags MKSH_A_UNUSED, const char *str, int slen, char ***wordsp)
|
|||||||
source = s;
|
source = s;
|
||||||
if (yylex(ONEWORD | LQCHAR) != LWORD) {
|
if (yylex(ONEWORD | LQCHAR) != LWORD) {
|
||||||
source = sold;
|
source = sold;
|
||||||
internal_warningf("%s: %s", "fileglob", "substitute error");
|
internal_warningf("%s: %s", "fileglob", "bad substitution");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
source = sold;
|
source = sold;
|
||||||
@ -2245,7 +2245,7 @@ x_vt_hack(int c)
|
|||||||
|
|
||||||
/*-
|
/*-
|
||||||
* At this point, we have read the following octets so far:
|
* At this point, we have read the following octets so far:
|
||||||
* - ESC+[ or ESC+O or Ctrl-X (Præfix 2)
|
* - ESC+[ or ESC+O or Ctrl-X (Prefix 2)
|
||||||
* - 1 (vt_hack)
|
* - 1 (vt_hack)
|
||||||
* - ;
|
* - ;
|
||||||
* - 5 (Ctrl key combiner) or 3 (Alt key combiner)
|
* - 5 (Ctrl key combiner) or 3 (Alt key combiner)
|
||||||
@ -2356,7 +2356,7 @@ x_bind(const char *a1, const char *a2,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (x_tab == NULL) {
|
if (x_tab == NULL) {
|
||||||
bi_errorf("cannot bind, not a tty");
|
bi_errorf("can't bind, not a tty");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
/* List function names */
|
/* List function names */
|
||||||
@ -2398,12 +2398,12 @@ x_bind(const char *a1, const char *a2,
|
|||||||
&& ((*m1 != '~') || *(m1 + 1))
|
&& ((*m1 != '~') || *(m1 + 1))
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
char msg[256] = "key sequence '";
|
char msg[256];
|
||||||
const char *c = a1;
|
const char *c = a1;
|
||||||
m1 = msg + strlen(msg);
|
m1 = msg;
|
||||||
while (*c && m1 < (msg + sizeof(msg) - 3))
|
while (*c && m1 < (msg + sizeof(msg) - 3))
|
||||||
x_mapout2(*c++, &m1);
|
x_mapout2(*c++, &m1);
|
||||||
bi_errorf("'%s' too long", msg);
|
bi_errorf("%s: %s '%s'", "bind", "too long key sequence", msg);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
#ifndef MKSH_SMALL
|
#ifndef MKSH_SMALL
|
||||||
@ -2428,7 +2428,7 @@ x_bind(const char *a1, const char *a2,
|
|||||||
strcmp(x_ftab[f].xf_name, a2) == 0)
|
strcmp(x_ftab[f].xf_name, a2) == 0)
|
||||||
break;
|
break;
|
||||||
if (f == NELEM(x_ftab) || x_ftab[f].xf_flags & XF_NOBIND) {
|
if (f == NELEM(x_ftab) || x_ftab[f].xf_flags & XF_NOBIND) {
|
||||||
bi_errorf("%s: %s", a2, "no such function");
|
bi_errorf("%s: %s %s", a2, "no such", T_function);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
eval.c
6
eval.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.91 2010/08/28 18:50:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.92 2010/08/28 20:22:16 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* string expansion
|
* string expansion
|
||||||
@ -108,7 +108,7 @@ substitute(const char *cp, int f)
|
|||||||
s->start = s->str = cp;
|
s->start = s->str = cp;
|
||||||
source = s;
|
source = s;
|
||||||
if (yylex(ONEWORD) != LWORD)
|
if (yylex(ONEWORD) != LWORD)
|
||||||
internal_errorf("substitute");
|
internal_errorf("bad substitution");
|
||||||
source = sold;
|
source = sold;
|
||||||
afree(s, ATEMP);
|
afree(s, ATEMP);
|
||||||
return (evalstr(yylval.cp, f));
|
return (evalstr(yylval.cp, f));
|
||||||
@ -1140,7 +1140,7 @@ comsub(Expand *xp, const char *cp)
|
|||||||
shf = shf_open(name = evalstr(io->name, DOTILDE), O_RDONLY, 0,
|
shf = shf_open(name = evalstr(io->name, DOTILDE), O_RDONLY, 0,
|
||||||
SHF_MAPHI|SHF_CLEXEC);
|
SHF_MAPHI|SHF_CLEXEC);
|
||||||
if (shf == NULL)
|
if (shf == NULL)
|
||||||
errorf("%s: %s", name, "cannot open $() input");
|
errorf("%s: %s %s", name, "can't open", "$() input");
|
||||||
xp->split = 0; /* no waitlast() */
|
xp->split = 0; /* no waitlast() */
|
||||||
} else {
|
} else {
|
||||||
int ofd1, pv[2];
|
int ofd1, pv[2];
|
||||||
|
46
exec.c
46
exec.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.79 2010/08/28 18:50:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.80 2010/08/28 20:22:17 tg Exp $");
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||||
@ -88,8 +88,8 @@ execute(struct op *volatile t,
|
|||||||
timex_hook(t, &up);
|
timex_hook(t, &up);
|
||||||
ap = (const char **)up;
|
ap = (const char **)up;
|
||||||
if (Flag(FXTRACE) && ap[0]) {
|
if (Flag(FXTRACE) && ap[0]) {
|
||||||
shf_fprintf(shl_out, "%s",
|
shf_puts(substitute(str_val(global("PS4")), 0),
|
||||||
substitute(str_val(global("PS4")), 0));
|
shl_out);
|
||||||
for (i = 0; ap[i]; i++)
|
for (i = 0; ap[i]; i++)
|
||||||
shf_fprintf(shl_out, "%s%c", ap[i],
|
shf_fprintf(shl_out, "%s%c", ap[i],
|
||||||
ap[i + 1] ? ' ' : '\n');
|
ap[i + 1] ? ' ' : '\n');
|
||||||
@ -534,8 +534,8 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
|
|||||||
|
|
||||||
if (Flag(FXTRACE)) {
|
if (Flag(FXTRACE)) {
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
shf_fprintf(shl_out, "%s",
|
shf_puts(substitute(str_val(global("PS4")), 0),
|
||||||
substitute(str_val(global("PS4")), 0));
|
shl_out);
|
||||||
shf_fprintf(shl_out, "%s%c", cp,
|
shf_fprintf(shl_out, "%s%c", cp,
|
||||||
t->vars[i + 1] ? ' ' : '\n');
|
t->vars[i + 1] ? ' ' : '\n');
|
||||||
if (!t->vars[i + 1])
|
if (!t->vars[i + 1])
|
||||||
@ -573,22 +573,24 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
|
|||||||
|
|
||||||
if (!tp->u.fpath) {
|
if (!tp->u.fpath) {
|
||||||
if (tp->u2.errno_) {
|
if (tp->u2.errno_) {
|
||||||
warningf(true, "%s: %s: %s", cp,
|
warningf(true, "%s: %s %s: %s", cp,
|
||||||
"can't find function definition file",
|
"can't find",
|
||||||
|
"function definition file",
|
||||||
strerror(tp->u2.errno_));
|
strerror(tp->u2.errno_));
|
||||||
rv = 126;
|
rv = 126;
|
||||||
} else {
|
} else {
|
||||||
warningf(true, "%s: %s", cp,
|
warningf(true, "%s: %s %s", cp,
|
||||||
"can't find function definition file");
|
"can't find",
|
||||||
|
"function definition file");
|
||||||
rv = 127;
|
rv = 127;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (include(tp->u.fpath, 0, NULL, 0) < 0) {
|
if (include(tp->u.fpath, 0, NULL, 0) < 0) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
warningf(true,
|
warningf(true, "%s: %s %s %s: %s", cp,
|
||||||
"%s: can't open function definition file %s: %s",
|
"can't open", "function definition file",
|
||||||
cp, tp->u.fpath, strerror(rv));
|
tp->u.fpath, strerror(rv));
|
||||||
rv = 127;
|
rv = 127;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -664,7 +666,7 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
|
|||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
default:
|
default:
|
||||||
quitenv(NULL);
|
quitenv(NULL);
|
||||||
internal_errorf("CFUNC %d", i);
|
internal_errorf("%s %d", "CFUNC", i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -679,7 +681,7 @@ comexec(struct op *t, struct tbl *volatile tp, const char **ap,
|
|||||||
*/
|
*/
|
||||||
if (tp->u2.errno_) {
|
if (tp->u2.errno_) {
|
||||||
warningf(true, "%s: %s: %s", cp,
|
warningf(true, "%s: %s: %s", cp,
|
||||||
"cannot execute", strerror(tp->u2.errno_));
|
"can't execute", strerror(tp->u2.errno_));
|
||||||
rv = 126; /* POSIX */
|
rv = 126; /* POSIX */
|
||||||
} else {
|
} else {
|
||||||
warningf(true, "%s: %s", cp, "not found");
|
warningf(true, "%s: %s", cp, "not found");
|
||||||
@ -1204,7 +1206,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
|||||||
/* herein() may already have printed message */
|
/* herein() may already have printed message */
|
||||||
if (u == -1) {
|
if (u == -1) {
|
||||||
u = errno;
|
u = errno;
|
||||||
warningf(true, "cannot %s %s: %s",
|
warningf(true, "can't %s %s: %s",
|
||||||
iotype == IODUP ? "dup" :
|
iotype == IODUP ? "dup" :
|
||||||
(iotype == IOREAD || iotype == IOHERE) ?
|
(iotype == IOREAD || iotype == IOHERE) ?
|
||||||
"open" : "create", cp, strerror(u));
|
"open" : "create", cp, strerror(u));
|
||||||
@ -1233,8 +1235,8 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
|||||||
int ev;
|
int ev;
|
||||||
|
|
||||||
ev = errno;
|
ev = errno;
|
||||||
warningf(true,
|
warningf(true, "%s %s %s",
|
||||||
"%s %s %s", "could not finish (dup) redirection",
|
"can't finish (dup) redirection",
|
||||||
snptreef(NULL, 32, "%R", &iotmp),
|
snptreef(NULL, 32, "%R", &iotmp),
|
||||||
strerror(ev));
|
strerror(ev));
|
||||||
if (iotype != IODUP)
|
if (iotype != IODUP)
|
||||||
@ -1273,7 +1275,7 @@ herein(const char *content, int sub)
|
|||||||
|
|
||||||
/* ksh -c 'cat << EOF' can cause this... */
|
/* ksh -c 'cat << EOF' can cause this... */
|
||||||
if (content == NULL) {
|
if (content == NULL) {
|
||||||
warningf(true, "here document missing");
|
warningf(true, "%s missing", "here document");
|
||||||
return (-2); /* special to iosetup(): don't print error */
|
return (-2); /* special to iosetup(): don't print error */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1317,9 +1319,7 @@ herein(const char *content, int sub)
|
|||||||
if (shf_close(shf) == EOF) {
|
if (shf_close(shf) == EOF) {
|
||||||
i = errno;
|
i = errno;
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = errno;
|
warningf(true, "%s: %s: %s", "write", h->name, strerror(i));
|
||||||
warningf(true, "error writing %s: %s, %s", h->name,
|
|
||||||
strerror(i), strerror(fd));
|
|
||||||
return (-2); /* special to iosetup(): don't print error */
|
return (-2); /* special to iosetup(): don't print error */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1349,7 +1349,7 @@ do_selectargs(const char **ap, bool print_menu)
|
|||||||
*/
|
*/
|
||||||
if (print_menu || !*str_val(global("REPLY")))
|
if (print_menu || !*str_val(global("REPLY")))
|
||||||
pr_menu(ap);
|
pr_menu(ap);
|
||||||
shellf("%s", str_val(global("PS3")));
|
shf_puts(str_val(global("PS3")), shl_out);
|
||||||
if (call_builtin(findcom("read", FC_BI), read_args))
|
if (call_builtin(findcom("read", FC_BI), read_args))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
s = str_val(global("REPLY"));
|
s = str_val(global("REPLY"));
|
||||||
@ -1430,7 +1430,7 @@ static char *plain_fmt_entry(char *, int, int, const void *);
|
|||||||
static char *
|
static char *
|
||||||
plain_fmt_entry(char *buf, int buflen, int i, const void *arg)
|
plain_fmt_entry(char *buf, int buflen, int i, const void *arg)
|
||||||
{
|
{
|
||||||
shf_snprintf(buf, buflen, "%s", ((const char * const *)arg)[i]);
|
strlcpy(buf, ((const char * const *)arg)[i], buflen);
|
||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
40
funcs.c
40
funcs.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.159 2010/08/28 18:50:51 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.160 2010/08/28 20:22:17 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -204,7 +204,7 @@ do_realpath(const char *upath)
|
|||||||
/* upath is a relative pathname, prepend cwd */
|
/* upath is a relative pathname, prepend cwd */
|
||||||
if ((tp = ksh_get_wd(NULL)) == NULL || tp[0] != '/')
|
if ((tp = ksh_get_wd(NULL)) == NULL || tp[0] != '/')
|
||||||
return (NULL);
|
return (NULL);
|
||||||
ipath = shf_smprintf("%s/%s", tp, upath);
|
ipath = shf_smprintf("%s%s%s", tp, "/", upath);
|
||||||
afree(tp, ATEMP);
|
afree(tp, ATEMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,7 +401,7 @@ c_cd(const char **wp)
|
|||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if (!current_wd[0]) {
|
if (!current_wd[0]) {
|
||||||
bi_errorf("don't know current directory");
|
bi_errorf("can't determine current directory");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
/* substitute arg1 for arg2 in current path.
|
/* substitute arg1 for arg2 in current path.
|
||||||
@ -521,7 +521,8 @@ c_pwd(const char **wp)
|
|||||||
if (p && access(p, R_OK) < 0)
|
if (p && access(p, R_OK) < 0)
|
||||||
p = NULL;
|
p = NULL;
|
||||||
if (!p && !(p = allocd = ksh_get_wd(NULL))) {
|
if (!p && !(p = allocd = ksh_get_wd(NULL))) {
|
||||||
bi_errorf("%s: %s", "can't get current directory", strerror(errno));
|
bi_errorf("%s: %s", "can't determine current directory",
|
||||||
|
strerror(errno));
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
shprintf("%s\n", p);
|
shprintf("%s\n", p);
|
||||||
@ -832,7 +833,7 @@ c_whence(const char **wp)
|
|||||||
shprintf(" (autoload from %s)",
|
shprintf(" (autoload from %s)",
|
||||||
tp->u.fpath);
|
tp->u.fpath);
|
||||||
}
|
}
|
||||||
shf_puts(" function", shl_stdout);
|
shf_puts(T__function, shl_stdout);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CSHELL:
|
case CSHELL:
|
||||||
@ -1057,11 +1058,11 @@ c_typeset(const char **wp)
|
|||||||
if (fset | fclr) {
|
if (fset | fclr) {
|
||||||
f->flag |= fset;
|
f->flag |= fset;
|
||||||
f->flag &= ~fclr;
|
f->flag &= ~fclr;
|
||||||
} else
|
} else {
|
||||||
fptreef(shl_stdout, 0,
|
fpFUNCTf(shl_stdout, 0, f->flag & FKSH,
|
||||||
f->flag & FKSH ?
|
wp[i], f->val.t);
|
||||||
"function %s %T\n" :
|
shf_putc('\n', shl_stdout);
|
||||||
"%s() %T\n", wp[i], f->val.t);
|
}
|
||||||
} else if (!typeset(wp[i], fset, fclr, field, base)) {
|
} else if (!typeset(wp[i], fset, fclr, field, base)) {
|
||||||
bi_errorf("%s: %s", wp[i], "not identifier");
|
bi_errorf("%s: %s", wp[i], "not identifier");
|
||||||
set_refflag = 0;
|
set_refflag = 0;
|
||||||
@ -1080,11 +1081,12 @@ c_typeset(const char **wp)
|
|||||||
if (flag && (vp->flag & flag) == 0)
|
if (flag && (vp->flag & flag) == 0)
|
||||||
continue;
|
continue;
|
||||||
if (thing == '-')
|
if (thing == '-')
|
||||||
fptreef(shl_stdout, 0, vp->flag & FKSH ?
|
fpFUNCTf(shl_stdout, 0,
|
||||||
"function %s %T\n" : "%s() %T\n",
|
vp->flag & FKSH,
|
||||||
vp->name, vp->val.t);
|
vp->name, vp->val.t);
|
||||||
else
|
else
|
||||||
shprintf("%s\n", vp->name);
|
shf_puts(vp->name, shl_stdout);
|
||||||
|
shf_putc('\n', shl_stdout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2049,7 +2051,7 @@ c_read(const char **wp)
|
|||||||
* (it also doesn't check the interactive flag,
|
* (it also doesn't check the interactive flag,
|
||||||
* as is indicated in the Kornshell book).
|
* as is indicated in the Kornshell book).
|
||||||
*/
|
*/
|
||||||
shellf("%s", cp+1);
|
shf_puts(cp + 1, shl_out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2136,7 +2138,7 @@ c_read(const char **wp)
|
|||||||
/* Must be done before setting export. */
|
/* Must be done before setting export. */
|
||||||
if (vp->flag & RDONLY) {
|
if (vp->flag & RDONLY) {
|
||||||
shf_flush(shf);
|
shf_flush(shf);
|
||||||
bi_errorf("%s is read only", *wp);
|
bi_errorf("%s: %s", *wp, "is read only");
|
||||||
afree(wpalloc, ATEMP);
|
afree(wpalloc, ATEMP);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@ -2338,7 +2340,7 @@ c_brkcont(const char **wp)
|
|||||||
* scripts, but don't generate an error (ie, keep going).
|
* scripts, but don't generate an error (ie, keep going).
|
||||||
*/
|
*/
|
||||||
if (n == quit) {
|
if (n == quit) {
|
||||||
warningf(true, "%s: %s %s", wp[0], "cannot", wp[0]);
|
warningf(true, "%s: %s %s", wp[0], "can't", wp[0]);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
/* POSIX says if n is too big, the last enclosing loop
|
/* POSIX says if n is too big, the last enclosing loop
|
||||||
@ -2433,7 +2435,7 @@ c_unset(const char **wp)
|
|||||||
afree(cp, ATEMP);
|
afree(cp, ATEMP);
|
||||||
|
|
||||||
if ((vp->flag&RDONLY)) {
|
if ((vp->flag&RDONLY)) {
|
||||||
bi_errorf("%s is read only", vp->name);
|
bi_errorf("%s: %s", vp->name, "is read only");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
unset(vp, optc);
|
unset(vp, optc);
|
||||||
@ -3352,7 +3354,7 @@ set_ulimit(const struct limits *l, const char *v, int how)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (getrlimit(l->resource, &limit) < 0) {
|
if (getrlimit(l->resource, &limit) < 0) {
|
||||||
/* some cannot be read, e.g. Linux RLIMIT_LOCKS */
|
/* some can't be read, e.g. Linux RLIMIT_LOCKS */
|
||||||
limit.rlim_cur = RLIM_INFINITY;
|
limit.rlim_cur = RLIM_INFINITY;
|
||||||
limit.rlim_max = RLIM_INFINITY;
|
limit.rlim_max = RLIM_INFINITY;
|
||||||
}
|
}
|
||||||
@ -3455,7 +3457,7 @@ c_cat(const char **wp)
|
|||||||
|
|
||||||
/* XXX uses malloc instead of lalloc (for alignment/speed) */
|
/* XXX uses malloc instead of lalloc (for alignment/speed) */
|
||||||
if ((buf = malloc(MKSH_CAT_BUFSIZ)) == NULL) {
|
if ((buf = malloc(MKSH_CAT_BUFSIZ)) == NULL) {
|
||||||
bi_errorf("cannot allocate %lu data bytes",
|
bi_errorf("can't allocate %lu data bytes",
|
||||||
(unsigned long)MKSH_CAT_BUFSIZ);
|
(unsigned long)MKSH_CAT_BUFSIZ);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
20
histrap.c
20
histrap.c
@ -26,7 +26,7 @@
|
|||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.100 2010/08/28 18:50:52 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/histrap.c,v 1.101 2010/08/28 20:22:18 tg Exp $");
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* MirOS: This is the default mapping type, and need not be specified.
|
* MirOS: This is the default mapping type, and need not be specified.
|
||||||
@ -79,7 +79,7 @@ c_fc(const char **wp)
|
|||||||
char **hfirst, **hlast, **hp;
|
char **hfirst, **hlast, **hp;
|
||||||
|
|
||||||
if (!Flag(FTALKING_I)) {
|
if (!Flag(FTALKING_I)) {
|
||||||
bi_errorf("history functions not available");
|
bi_errorf("history %ss not available", T_function);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,8 +307,10 @@ hist_execute(char *cmd)
|
|||||||
}
|
}
|
||||||
histsave(&hist_source->line, p, true, true);
|
histsave(&hist_source->line, p, true, true);
|
||||||
|
|
||||||
shellf("%s\n", p); /* POSIX doesn't say this is done... */
|
/* POSIX doesn't say this is done... */
|
||||||
if (q) /* restore \n (trailing \n not restored) */
|
shellf("%s\n", p);
|
||||||
|
if (q)
|
||||||
|
/* restore \n (trailing \n not restored) */
|
||||||
q[-1] = '\n';
|
q[-1] = '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,7 +356,7 @@ hist_replace(char **hp, const char *pat, const char *rep, bool globr)
|
|||||||
xp += rep_len;
|
xp += rep_len;
|
||||||
}
|
}
|
||||||
if (!any_subst) {
|
if (!any_subst) {
|
||||||
bi_errorf("substitution failed");
|
bi_errorf("bad substitution");
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
len = strlen(s) + 1;
|
len = strlen(s) + 1;
|
||||||
@ -748,8 +750,9 @@ hist_init(Source *s)
|
|||||||
hist_finish();
|
hist_finish();
|
||||||
if (rv) {
|
if (rv) {
|
||||||
hiniterr:
|
hiniterr:
|
||||||
bi_errorf("cannot unlink HISTFILE %s"
|
bi_errorf("can't %s %s: %s",
|
||||||
" - %s", hname, strerror(errno));
|
"unlink HISTFILE", hname,
|
||||||
|
strerror(errno));
|
||||||
hsize = 0;
|
hsize = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1087,7 +1090,8 @@ inittraps(void)
|
|||||||
#endif
|
#endif
|
||||||
if ((sigtraps[i].mess == NULL) ||
|
if ((sigtraps[i].mess == NULL) ||
|
||||||
(sigtraps[i].mess[0] == '\0'))
|
(sigtraps[i].mess[0] == '\0'))
|
||||||
sigtraps[i].mess = shf_smprintf("Signal %d", i);
|
sigtraps[i].mess = shf_smprintf("%s %d",
|
||||||
|
"Signal", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sigtraps[SIGEXIT_].name = "EXIT"; /* our name for signal 0 */
|
sigtraps[SIGEXIT_].name = "EXIT"; /* our name for signal 0 */
|
||||||
|
49
jobs.c
49
jobs.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.71 2010/08/28 18:50:53 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.72 2010/08/28 20:22:19 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
#define mksh_killpg killpg
|
#define mksh_killpg killpg
|
||||||
@ -276,8 +276,8 @@ j_change(void)
|
|||||||
pid_t ttypgrp;
|
pid_t ttypgrp;
|
||||||
|
|
||||||
if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) {
|
if ((ttypgrp = tcgetpgrp(tty_fd)) < 0) {
|
||||||
warningf(false, "%s: %s: %s", "j_init",
|
warningf(false, "%s: %s %s: %s",
|
||||||
"tcgetpgrp() failed",
|
"j_init", "tcgetpgrp", "failed",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
ttypgrp_ok = false;
|
ttypgrp_ok = false;
|
||||||
break;
|
break;
|
||||||
@ -292,14 +292,13 @@ j_change(void)
|
|||||||
SS_RESTORE_DFL|SS_FORCE);
|
SS_RESTORE_DFL|SS_FORCE);
|
||||||
if (ttypgrp_ok && kshpgrp != kshpid) {
|
if (ttypgrp_ok && kshpgrp != kshpid) {
|
||||||
if (setpgid(0, kshpid) < 0) {
|
if (setpgid(0, kshpid) < 0) {
|
||||||
warningf(false, "%s: %s: %s", "j_init",
|
warningf(false, "%s: %s %s: %s", "j_init",
|
||||||
"setpgid() failed",
|
"setpgid", "failed", strerror(errno));
|
||||||
strerror(errno));
|
|
||||||
ttypgrp_ok = false;
|
ttypgrp_ok = false;
|
||||||
} else {
|
} else {
|
||||||
if (tcsetpgrp(tty_fd, kshpid) < 0) {
|
if (tcsetpgrp(tty_fd, kshpid) < 0) {
|
||||||
warningf(false, "%s: %s: %s", "j_init",
|
warningf(false, "%s: %s %s: %s",
|
||||||
"tcsetpgrp() failed",
|
"j_init", "tcsetpgrp", "failed",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
ttypgrp_ok = false;
|
ttypgrp_ok = false;
|
||||||
} else
|
} else
|
||||||
@ -369,8 +368,8 @@ exchild(struct op *t, int flags,
|
|||||||
if (flags & XPIPEI) {
|
if (flags & XPIPEI) {
|
||||||
/* continuing with a pipe */
|
/* continuing with a pipe */
|
||||||
if (!last_job)
|
if (!last_job)
|
||||||
internal_errorf(
|
internal_errorf("%s %d",
|
||||||
"exchild: XPIPEI and no last_job - pid %d",
|
"exchild: XPIPEI and no last_job - pid",
|
||||||
(int)procpid);
|
(int)procpid);
|
||||||
pi.j = last_job;
|
pi.j = last_job;
|
||||||
if (last_proc)
|
if (last_proc)
|
||||||
@ -411,7 +410,7 @@ exchild(struct op *t, int flags,
|
|||||||
kill_job(pi.j, SIGKILL);
|
kill_job(pi.j, SIGKILL);
|
||||||
remove_job(pi.j, "fork failed");
|
remove_job(pi.j, "fork failed");
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
errorf("cannot fork - try again");
|
errorf("can't fork - try again");
|
||||||
}
|
}
|
||||||
pi.p->pid = pi.cldpid ? pi.cldpid : (procpid = getpid());
|
pi.p->pid = pi.cldpid ? pi.cldpid : (procpid = getpid());
|
||||||
|
|
||||||
@ -570,7 +569,7 @@ waitlast(void)
|
|||||||
return (125); /* not so arbitrary, non-zero value */
|
return (125); /* not so arbitrary, non-zero value */
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = j_waitj(j, JW_NONE, "jw:waitlast");
|
rv = j_waitj(j, JW_NONE, "waitlast");
|
||||||
|
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
|
|
||||||
@ -729,10 +728,10 @@ j_resume(const char *cp, int bg)
|
|||||||
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
||||||
sigprocmask(SIG_SETMASK, &omask,
|
sigprocmask(SIG_SETMASK, &omask,
|
||||||
NULL);
|
NULL);
|
||||||
bi_errorf("1st tcsetpgrp(%d, %d) failed: %s",
|
bi_errorf("%s %s(%d, %ld) %s: %s",
|
||||||
tty_fd,
|
"1st", "tcsetpgrp", tty_fd,
|
||||||
(int)((j->flags & JF_SAVEDTTYPGRP) ?
|
(long)((j->flags & JF_SAVEDTTYPGRP) ?
|
||||||
j->saved_ttypgrp : j->pgrp),
|
j->saved_ttypgrp : j->pgrp), "failed",
|
||||||
strerror(rv));
|
strerror(rv));
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@ -751,12 +750,12 @@ j_resume(const char *cp, int bg)
|
|||||||
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
|
if (ttypgrp_ok && (j->flags & JF_SAVEDTTY))
|
||||||
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
tcsetattr(tty_fd, TCSADRAIN, &tty_state);
|
||||||
if (ttypgrp_ok && tcsetpgrp(tty_fd, kshpgrp) < 0)
|
if (ttypgrp_ok && tcsetpgrp(tty_fd, kshpgrp) < 0)
|
||||||
warningf(true,
|
warningf(true, "%s %s(%d, %ld) %s: %s",
|
||||||
"fg: 2nd tcsetpgrp(%d, %ld) failed: %s",
|
"fg: 2nd", "tcsetpgrp", tty_fd,
|
||||||
tty_fd, (long)kshpgrp, strerror(errno));
|
(long)kshpgrp, "failed", strerror(errno));
|
||||||
}
|
}
|
||||||
sigprocmask(SIG_SETMASK, &omask, NULL);
|
sigprocmask(SIG_SETMASK, &omask, NULL);
|
||||||
bi_errorf("%s %s %s", "cannot continue job",
|
bi_errorf("%s %s %s", "can't continue job",
|
||||||
cp, strerror(err));
|
cp, strerror(err));
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@ -1023,9 +1022,9 @@ j_waitj(Job *j,
|
|||||||
(j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0)
|
(j->saved_ttypgrp = tcgetpgrp(tty_fd)) >= 0)
|
||||||
j->flags |= JF_SAVEDTTYPGRP;
|
j->flags |= JF_SAVEDTTYPGRP;
|
||||||
if (tcsetpgrp(tty_fd, kshpgrp) < 0)
|
if (tcsetpgrp(tty_fd, kshpgrp) < 0)
|
||||||
warningf(true,
|
warningf(true, "%s %s(%d, %ld) %s: %s",
|
||||||
"j_waitj: tcsetpgrp(%d, %ld) failed: %s",
|
"j_waitj:", "tcsetpgrp", tty_fd,
|
||||||
tty_fd, (long)kshpgrp, strerror(errno));
|
(long)kshpgrp, "failed", strerror(errno));
|
||||||
if (j->state == PSTOPPED) {
|
if (j->state == PSTOPPED) {
|
||||||
j->flags |= JF_SAVEDTTY;
|
j->flags |= JF_SAVEDTTY;
|
||||||
tcgetattr(tty_fd, &j->ttystat);
|
tcgetattr(tty_fd, &j->ttystat);
|
||||||
@ -1373,7 +1372,7 @@ j_print(Job *j, int how, struct shf *shf)
|
|||||||
if (p == j->proc_list)
|
if (p == j->proc_list)
|
||||||
shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
|
shf_fprintf(shf, "[%d] %c ", j->job, jobchar);
|
||||||
else
|
else
|
||||||
shf_fprintf(shf, "%s", filler);
|
shf_puts(filler, shf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (how == JP_LONG)
|
if (how == JP_LONG)
|
||||||
@ -1570,7 +1569,7 @@ remove_job(Job *j, const char *where)
|
|||||||
for (; curr != NULL && curr != j; prev = &curr->next, curr = *prev)
|
for (; curr != NULL && curr != j; prev = &curr->next, curr = *prev)
|
||||||
;
|
;
|
||||||
if (curr != j) {
|
if (curr != j) {
|
||||||
internal_warningf("remove_job: job not found (%s)", where);
|
internal_warningf("remove_job: job %s (%s)", "not found", where);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*prev = curr->next;
|
*prev = curr->next;
|
||||||
|
15
lalloc.c
15
lalloc.c
@ -1,26 +1,26 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright © 2009
|
* Copyright (c) 2009, 2010
|
||||||
* Thorsten Glaser <tg@mirbsd.org>
|
* Thorsten Glaser <tg@mirbsd.org>
|
||||||
*
|
*
|
||||||
* Provided that these terms and disclaimer and all copyright notices
|
* Provided that these terms and disclaimer and all copyright notices
|
||||||
* are retained or reproduced in an accompanying document, permission
|
* are retained or reproduced in an accompanying document, permission
|
||||||
* is granted to deal in this work without restriction, including un‐
|
* is granted to deal in this work without restriction, including un-
|
||||||
* limited rights to use, publicly perform, distribute, sell, modify,
|
* limited rights to use, publicly perform, distribute, sell, modify,
|
||||||
* merge, give away, or sublicence.
|
* merge, give away, or sublicence.
|
||||||
*
|
*
|
||||||
* This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
|
* This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
|
||||||
* the utmost extent permitted by applicable law, neither express nor
|
* the utmost extent permitted by applicable law, neither express nor
|
||||||
* implied; without malicious intent or gross negligence. In no event
|
* implied; without malicious intent or gross negligence. In no event
|
||||||
* may a licensor, author or contributor be held liable for indirect,
|
* may a licensor, author or contributor be held liable for indirect,
|
||||||
* direct, other damage, loss, or other issues arising in any way out
|
* direct, other damage, loss, or other issues arising in any way out
|
||||||
* of dealing in the work, even if advised of the possibility of such
|
* of dealing in the work, even if advised of the possibility of such
|
||||||
* damage or existence of a defect, except proven that it results out
|
* damage or existence of a defect, except proven that it results out
|
||||||
* of said person’s immediate fault when using the work as intended.
|
* of said person's immediate fault when using the work as intended.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.11 2009/08/08 13:08:51 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.12 2010/08/28 20:22:19 tg Exp $");
|
||||||
|
|
||||||
/* build with CPPFLAGS+= -DUSE_REALLOC_MALLOC=0 on ancient systems */
|
/* build with CPPFLAGS+= -DUSE_REALLOC_MALLOC=0 on ancient systems */
|
||||||
#if defined(USE_REALLOC_MALLOC) && (USE_REALLOC_MALLOC == 0)
|
#if defined(USE_REALLOC_MALLOC) && (USE_REALLOC_MALLOC == 0)
|
||||||
@ -61,7 +61,8 @@ findptr(ALLOC_ITEM **lpp, char *ptr, Area *ap)
|
|||||||
#ifndef MKSH_SMALL
|
#ifndef MKSH_SMALL
|
||||||
fail:
|
fail:
|
||||||
#endif
|
#endif
|
||||||
internal_errorf("rogue pointer %p", ptr);
|
internal_errorf("rogue pointer %lX",
|
||||||
|
(long)(ptrdiff_t)ptr);
|
||||||
}
|
}
|
||||||
return (ap);
|
return (ap);
|
||||||
}
|
}
|
||||||
@ -85,7 +86,7 @@ aresize(void *ptr, size_t numb, Area *ap)
|
|||||||
|| ALLOC_ISUNALIGNED(lp)
|
|| ALLOC_ISUNALIGNED(lp)
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
internal_errorf("cannot allocate %lu data bytes",
|
internal_errorf("can't allocate %lu data bytes",
|
||||||
(unsigned long)numb);
|
(unsigned long)numb);
|
||||||
/* this only works because Area is an ALLOC_ITEM */
|
/* this only works because Area is an ALLOC_ITEM */
|
||||||
lp->next = ap->next;
|
lp->next = ap->next;
|
||||||
|
7
lex.c
7
lex.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.119 2010/08/28 18:50:53 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.120 2010/08/28 20:22:20 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* states while lexing word
|
* states while lexing word
|
||||||
@ -944,7 +944,7 @@ yylex(int cf)
|
|||||||
|
|
||||||
#ifndef MKSH_SMALL
|
#ifndef MKSH_SMALL
|
||||||
if (state == SLETARRAY && statep->ls_sletarray.nparen != -1)
|
if (state == SLETARRAY && statep->ls_sletarray.nparen != -1)
|
||||||
yyerror("%s: '%s' %s\n", T_synerr, ")", "missing");
|
yyerror("%s: %s\n", T_synerr, "missing )");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This done to avoid tests for SHEREDELIM wherever SBASE tested */
|
/* This done to avoid tests for SHEREDELIM wherever SBASE tested */
|
||||||
@ -1207,7 +1207,8 @@ readhere(struct ioword *iop)
|
|||||||
ungetsc(c);
|
ungetsc(c);
|
||||||
while ((c = getsc()) != '\n') {
|
while ((c = getsc()) != '\n') {
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
yyerror("here document '%s' unclosed\n", eof);
|
yyerror("%s '%s' unclosed\n", "here document",
|
||||||
|
eof);
|
||||||
Xcheck(xs, xp);
|
Xcheck(xs, xp);
|
||||||
Xput(xs, xp, c);
|
Xput(xs, xp, c);
|
||||||
}
|
}
|
||||||
|
23
main.c
23
main.c
@ -33,7 +33,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.169 2010/08/28 18:50:54 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.170 2010/08/28 20:22:20 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ mksh_init(int argc, const char *argv[])
|
|||||||
* user will know why things broke.
|
* user will know why things broke.
|
||||||
*/
|
*/
|
||||||
if (!current_wd[0] && Flag(FTALKING))
|
if (!current_wd[0] && Flag(FTALKING))
|
||||||
warningf(false, "Cannot determine current working directory");
|
warningf(false, "can't determine current directory");
|
||||||
|
|
||||||
if (Flag(FLOGIN)) {
|
if (Flag(FLOGIN)) {
|
||||||
include(KSH_SYSTEM_PROFILE, 0, NULL, 1);
|
include(KSH_SYSTEM_PROFILE, 0, NULL, 1);
|
||||||
@ -475,7 +475,7 @@ main(int argc, const char *argv[])
|
|||||||
if ((s = mksh_init(argc, argv))) {
|
if ((s = mksh_init(argc, argv))) {
|
||||||
/* put more entropy into the LCG */
|
/* put more entropy into the LCG */
|
||||||
change_random(s, sizeof(*s));
|
change_random(s, sizeof(*s));
|
||||||
/* doesn’t return */
|
/* doesn't return */
|
||||||
shell(s, true);
|
shell(s, true);
|
||||||
}
|
}
|
||||||
return (1);
|
return (1);
|
||||||
@ -526,7 +526,7 @@ include(const char *name, int argc, const char **argv, int intr_ok)
|
|||||||
unwind(i);
|
unwind(i);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
default:
|
default:
|
||||||
internal_errorf("include: %d", i);
|
internal_errorf("%s %d", "include", i);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -612,7 +612,7 @@ shell(Source * volatile s, volatile int toplevel)
|
|||||||
default:
|
default:
|
||||||
source = old_source;
|
source = old_source;
|
||||||
quitenv(NULL);
|
quitenv(NULL);
|
||||||
internal_errorf("shell: %d", i);
|
internal_errorf("%s %d", "shell", i);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -857,8 +857,8 @@ tty_init(bool init_ttystate, bool need_tty)
|
|||||||
if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) {
|
if ((tfd = open("/dev/tty", O_RDWR, 0)) < 0) {
|
||||||
tty_devtty = 0;
|
tty_devtty = 0;
|
||||||
if (need_tty)
|
if (need_tty)
|
||||||
warningf(false,
|
warningf(false, "%s: %s %s: %s",
|
||||||
"No controlling tty (open /dev/tty: %s)",
|
"No controlling tty", "open", "/dev/tty",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
if (tfd < 0) {
|
if (tfd < 0) {
|
||||||
@ -869,15 +869,14 @@ tty_init(bool init_ttystate, bool need_tty)
|
|||||||
tfd = 2;
|
tfd = 2;
|
||||||
else {
|
else {
|
||||||
if (need_tty)
|
if (need_tty)
|
||||||
warningf(false,
|
warningf(false, "can't find tty fd");
|
||||||
"Can't find tty file descriptor");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((tty_fd = fcntl(tfd, F_DUPFD, FDBASE)) < 0) {
|
if ((tty_fd = fcntl(tfd, F_DUPFD, FDBASE)) < 0) {
|
||||||
if (need_tty)
|
if (need_tty)
|
||||||
warningf(false, "%s: %s: %s", "j_ttyinit",
|
warningf(false, "%s: %s %s: %s", "j_ttyinit",
|
||||||
"dup of tty fd failed", strerror(errno));
|
"dup of tty fd", "failed", strerror(errno));
|
||||||
} else if (fcntl(tty_fd, F_SETFD, FD_CLOEXEC) < 0) {
|
} else if (fcntl(tty_fd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||||
if (need_tty)
|
if (need_tty)
|
||||||
warningf(false, "%s: %s: %s", "j_ttyinit",
|
warningf(false, "%s: %s: %s", "j_ttyinit",
|
||||||
@ -1279,7 +1278,7 @@ maketemp(Area *ap, Temp_type type, struct temp **tlist)
|
|||||||
tp->shf = NULL;
|
tp->shf = NULL;
|
||||||
tp->type = type;
|
tp->type = type;
|
||||||
#if HAVE_MKSTEMP
|
#if HAVE_MKSTEMP
|
||||||
shf_snprintf(pathname, len, "%s/%s", dir, "mksh.XXXXXXXXXX");
|
shf_snprintf(pathname, len, "%s%s", dir, "/mksh.XXXXXXXXXX");
|
||||||
if ((fd = mkstemp(pathname)) >= 0)
|
if ((fd = mkstemp(pathname)) >= 0)
|
||||||
#else
|
#else
|
||||||
if (tp->name[0] && (fd = open(tp->name, O_CREAT | O_RDWR, 0600)) >= 0)
|
if (tp->name[0] && (fd = open(tp->name, O_CREAT | O_RDWR, 0600)) >= 0)
|
||||||
|
22
misc.c
22
misc.c
@ -29,7 +29,7 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.144 2010/08/28 18:50:55 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.145 2010/08/28 20:22:21 tg Exp $");
|
||||||
|
|
||||||
unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */
|
unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ printoptions(bool verbose)
|
|||||||
print_columns(shl_stdout, n, options_fmt_entry, &oi,
|
print_columns(shl_stdout, n, options_fmt_entry, &oi,
|
||||||
octs + 4, oi.opt_width + 4, true);
|
octs + 4, oi.opt_width + 4, true);
|
||||||
} else {
|
} else {
|
||||||
/* short version á la AT&T ksh93 */
|
/* short version like AT&T ksh93 */
|
||||||
shf_puts(T_set, shl_stdout);
|
shf_puts(T_set, shl_stdout);
|
||||||
while (i < (int)NELEM(options)) {
|
while (i < (int)NELEM(options)) {
|
||||||
if (Flag(i) && options[i].name)
|
if (Flag(i) && options[i].name)
|
||||||
@ -833,9 +833,10 @@ ksh_getopt(const char **argv, Getopt *go, const char *optionsp)
|
|||||||
go->buf[0] = c;
|
go->buf[0] = c;
|
||||||
go->optarg = go->buf;
|
go->optarg = go->buf;
|
||||||
} else {
|
} else {
|
||||||
warningf(true, "%s%s-%c: unknown option",
|
warningf(true, "%s%s-%c: %s",
|
||||||
(go->flags & GF_NONAME) ? "" : argv[0],
|
(go->flags & GF_NONAME) ? "" : argv[0],
|
||||||
(go->flags & GF_NONAME) ? "" : ": ", c);
|
(go->flags & GF_NONAME) ? "" : ": ", c,
|
||||||
|
"unknown option");
|
||||||
if (go->flags & GF_ERROR)
|
if (go->flags & GF_ERROR)
|
||||||
bi_errorfz();
|
bi_errorfz();
|
||||||
}
|
}
|
||||||
@ -859,7 +860,7 @@ ksh_getopt(const char **argv, Getopt *go, const char *optionsp)
|
|||||||
go->optarg = go->buf;
|
go->optarg = go->buf;
|
||||||
return (':');
|
return (':');
|
||||||
}
|
}
|
||||||
warningf(true, "%s%s-'%c' %s",
|
warningf(true, "%s%s-%c: %s",
|
||||||
(go->flags & GF_NONAME) ? "" : argv[0],
|
(go->flags & GF_NONAME) ? "" : argv[0],
|
||||||
(go->flags & GF_NONAME) ? "" : ": ", c,
|
(go->flags & GF_NONAME) ? "" : ": ", c,
|
||||||
"requires an argument");
|
"requires an argument");
|
||||||
@ -1299,19 +1300,20 @@ chvt(const char *fn)
|
|||||||
if (!(sb.st_mode & S_IFCHR))
|
if (!(sb.st_mode & S_IFCHR))
|
||||||
errorf("%s %s %s", "chvt: not a char", "device", fn);
|
errorf("%s %s %s", "chvt: not a char", "device", fn);
|
||||||
if ((sb.st_uid != 0) && chown(fn, 0, 0))
|
if ((sb.st_uid != 0) && chown(fn, 0, 0))
|
||||||
warningf(false, "%s: %s %s", "chvt", "cannot chown root", fn);
|
warningf(false, "%s: %s %s", "chvt", "can't chown root", fn);
|
||||||
if (((sb.st_mode & 07777) != 0600) && chmod(fn, (mode_t)0600))
|
if (((sb.st_mode & 07777) != 0600) && chmod(fn, (mode_t)0600))
|
||||||
warningf(false, "%s: %s %s", "chvt", "cannot chmod 0600", fn);
|
warningf(false, "%s: %s %s", "chvt", "can't chmod 0600", fn);
|
||||||
#if HAVE_REVOKE
|
#if HAVE_REVOKE
|
||||||
if (revoke(fn))
|
if (revoke(fn))
|
||||||
#endif
|
#endif
|
||||||
warningf(false, "%s: cannot revoke %s, new shell is"
|
warningf(false, "%s: %s %s", "chvt",
|
||||||
" potentially insecure", "chvt", fn);
|
"new shell is potentially insecure, can't revoke",
|
||||||
|
fn);
|
||||||
}
|
}
|
||||||
if ((fd = open(fn, O_RDWR)) == -1) {
|
if ((fd = open(fn, O_RDWR)) == -1) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
if ((fd = open(fn, O_RDWR)) == -1)
|
if ((fd = open(fn, O_RDWR)) == -1)
|
||||||
errorf("%s: %s %s", "chvt", "cannot open", fn);
|
errorf("%s: %s %s", "chvt", "can't open", fn);
|
||||||
}
|
}
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
|
5
sh.h
5
sh.h
@ -150,7 +150,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.410 2010/08/28 18:50:55 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.411 2010/08/28 20:22:22 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R39 2010/08/28"
|
#define MKSH_VERSION "R39 2010/08/28"
|
||||||
|
|
||||||
@ -641,6 +641,8 @@ EXTERN const char T_sgset[] I__("*=set");
|
|||||||
#define T_set (T_sgset + 2) /* "set" */
|
#define T_set (T_sgset + 2) /* "set" */
|
||||||
EXTERN const char T_gbuiltin[] I__("=builtin");
|
EXTERN const char T_gbuiltin[] I__("=builtin");
|
||||||
#define T_builtin (T_gbuiltin + 1) /* "builtin" */
|
#define T_builtin (T_gbuiltin + 1) /* "builtin" */
|
||||||
|
EXTERN const char T__function[] I__(" function");
|
||||||
|
#define T_function (T__function + 1) /* "function" */
|
||||||
|
|
||||||
enum temp_type {
|
enum temp_type {
|
||||||
TT_HEREDOC_EXP, /* expanded heredoc */
|
TT_HEREDOC_EXP, /* expanded heredoc */
|
||||||
@ -1668,6 +1670,7 @@ char *wdcopy(const char *, Area *);
|
|||||||
const char *wdscan(const char *, int);
|
const char *wdscan(const char *, int);
|
||||||
char *wdstrip(const char *, bool, bool);
|
char *wdstrip(const char *, bool, bool);
|
||||||
void tfree(struct op *, Area *);
|
void tfree(struct op *, Area *);
|
||||||
|
int fpFUNCTf(struct shf *, int, bool, const char *, struct op *);
|
||||||
/* var.c */
|
/* var.c */
|
||||||
void newblock(void);
|
void newblock(void);
|
||||||
void popblock(void);
|
void popblock(void);
|
||||||
|
13
shf.c
13
shf.c
@ -18,11 +18,13 @@
|
|||||||
* of dealing in the work, even if advised of the possibility of such
|
* of dealing in the work, even if advised of the possibility of such
|
||||||
* damage or existence of a defect, except proven that it results out
|
* damage or existence of a defect, except proven that it results out
|
||||||
* of said person's immediate fault when using the work as intended.
|
* of said person's immediate fault when using the work as intended.
|
||||||
|
*-
|
||||||
|
* Use %lX instead of %p and floating point isn't supported at all.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.38 2010/08/28 18:50:57 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.39 2010/08/28 20:22:23 tg Exp $");
|
||||||
|
|
||||||
/* flags to shf_emptybuf() */
|
/* flags to shf_emptybuf() */
|
||||||
#define EB_READSW 0x01 /* about to switch to reading */
|
#define EB_READSW 0x01 /* about to switch to reading */
|
||||||
@ -704,7 +706,8 @@ shf_snprintf(char *buf, int bsize, const char *fmt, ...)
|
|||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (!buf || bsize <= 0)
|
if (!buf || bsize <= 0)
|
||||||
internal_errorf("shf_snprintf: buf %p, bsize %d", buf, bsize);
|
internal_errorf("shf_snprintf: buf %lX, bsize %d",
|
||||||
|
(long)(ptrdiff_t)buf, bsize);
|
||||||
|
|
||||||
shf_sopen(buf, bsize, SHF_WR, &shf);
|
shf_sopen(buf, bsize, SHF_WR, &shf);
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
@ -854,11 +857,6 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'p': /* pointer */
|
|
||||||
flags &= ~(FL_LONG | FL_SHORT);
|
|
||||||
flags |= (sizeof(char *) > sizeof(int)) ?
|
|
||||||
/* hope it fits.. */ FL_LONG : 0;
|
|
||||||
/* aaahhh... */
|
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
case 'o':
|
case 'o':
|
||||||
@ -916,7 +914,6 @@ shf_vfprintf(struct shf *shf, const char *fmt, va_list args)
|
|||||||
*--cp = '0';
|
*--cp = '0';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
|
||||||
case 'x': {
|
case 'x': {
|
||||||
const char *digits = (flags & FL_UPPER) ?
|
const char *digits = (flags & FL_UPPER) ?
|
||||||
digits_uc : digits_lc;
|
digits_uc : digits_lc;
|
||||||
|
6
syn.c
6
syn.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.50 2010/08/28 18:50:58 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/syn.c,v 1.51 2010/08/28 20:22:23 tg Exp $");
|
||||||
|
|
||||||
struct nesting_state {
|
struct nesting_state {
|
||||||
int start_token; /* token than began nesting (eg, FOR) */
|
int start_token; /* token than began nesting (eg, FOR) */
|
||||||
@ -740,7 +740,7 @@ const struct tokeninfo {
|
|||||||
{ "do", DO, true },
|
{ "do", DO, true },
|
||||||
{ "done", DONE, true },
|
{ "done", DONE, true },
|
||||||
{ "in", IN, true },
|
{ "in", IN, true },
|
||||||
{ "function", FUNCTION, true },
|
{ T_function, FUNCTION, true },
|
||||||
{ "time", TIME, true },
|
{ "time", TIME, true },
|
||||||
{ "{", '{', true },
|
{ "{", '{', true },
|
||||||
{ "}", '}', true },
|
{ "}", '}', true },
|
||||||
@ -797,7 +797,7 @@ syntaxerr(const char *what)
|
|||||||
goto Again;
|
goto Again;
|
||||||
}
|
}
|
||||||
/* don't quote the EOF */
|
/* don't quote the EOF */
|
||||||
yyerror("%s: %s\n", T_synerr, "unexpected EOF");
|
yyerror("%s: %s %s\n", T_synerr, "unexpected", "EOF");
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
|
|
||||||
case LWORD:
|
case LWORD:
|
||||||
|
17
tree.c
17
tree.c
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.30 2010/02/25 20:18:19 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/tree.c,v 1.31 2010/08/28 20:22:24 tg Exp $");
|
||||||
|
|
||||||
#define INDENT 4
|
#define INDENT 4
|
||||||
|
|
||||||
@ -164,12 +164,10 @@ ptree(struct op *t, int indent, struct shf *shf)
|
|||||||
fptreef(shf, indent, "%T& ", t->left);
|
fptreef(shf, indent, "%T& ", t->left);
|
||||||
break;
|
break;
|
||||||
case TFUNCT:
|
case TFUNCT:
|
||||||
fptreef(shf, indent,
|
fpFUNCTf(shf, indent, t->u.ksh_func, t->str, t->left);
|
||||||
t->u.ksh_func ? "function %s %T" : "%s() %T",
|
|
||||||
t->str, t->left);
|
|
||||||
break;
|
break;
|
||||||
case TTIME:
|
case TTIME:
|
||||||
fptreef(shf, indent, "time %T", t->left);
|
fptreef(shf, indent, "%s %T", "time", t->left);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
shf_puts("<botch>", shf);
|
shf_puts("<botch>", shf);
|
||||||
@ -714,3 +712,12 @@ iofree(struct ioword **iow, Area *ap)
|
|||||||
}
|
}
|
||||||
afree(iow, ap);
|
afree(iow, ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
fpFUNCTf(struct shf *shf, int i, bool isksh, const char *k, struct op *v)
|
||||||
|
{
|
||||||
|
if (isksh)
|
||||||
|
return (fptreef(shf, i, "%s %s %T", T_function, k, v));
|
||||||
|
else
|
||||||
|
return (fptreef(shf, i, "%s() %T", k, v));
|
||||||
|
}
|
||||||
|
8
var.c
8
var.c
@ -26,7 +26,7 @@
|
|||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.111 2010/08/28 18:50:58 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.112 2010/08/28 20:22:24 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables
|
* Variables
|
||||||
@ -686,7 +686,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
|
|||||||
if (*val == '[') {
|
if (*val == '[') {
|
||||||
if (set_refflag)
|
if (set_refflag)
|
||||||
errorf("%s: %s", var,
|
errorf("%s: %s", var,
|
||||||
"reference variable cannot be an array");
|
"reference variable can't be an array");
|
||||||
len = array_ref_len(val);
|
len = array_ref_len(val);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -712,7 +712,7 @@ typeset(const char *var, Tflag set, Tflag clr, int field, int base)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
strdupx(tvar, var, ATEMP);
|
strdupx(tvar, var, ATEMP);
|
||||||
val = NULL;
|
val = NULL;
|
||||||
/* handle foo[*] ⇒ foo (whole array) mapping for R39b */
|
/* handle foo[*] => foo (whole array) mapping for R39b */
|
||||||
len = strlen(tvar);
|
len = strlen(tvar);
|
||||||
if (len > 3 && tvar[len-3] == '[' && tvar[len-2] == '*' &&
|
if (len > 3 && tvar[len-3] == '[' && tvar[len-2] == '*' &&
|
||||||
tvar[len-1] == ']')
|
tvar[len-1] == ']')
|
||||||
@ -1051,7 +1051,7 @@ change_random(const void *vp, size_t n)
|
|||||||
h = oaathash_update(h, k, sizeof(k));
|
h = oaathash_update(h, k, sizeof(k));
|
||||||
kshstate_v.lcg_state_ = oaathash_finalise(h);
|
kshstate_v.lcg_state_ = oaathash_finalise(h);
|
||||||
#elif defined(MKSH_A4PB)
|
#elif defined(MKSH_A4PB)
|
||||||
/* forced by the user to use arc4random_pushb(3) • Cygwin? */
|
/* forced by the user to use arc4random_pushb(3) - Cygwin? */
|
||||||
{
|
{
|
||||||
uint32_t prv;
|
uint32_t prv;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user