• revert the cat hack for realpath and rename
‣ I was convinced by several that more magic is never the solution • fix a comment: function cat already had precedence • change cat loader to look for existence, FPATH included, before ditching the builtin; note that in manpage
This commit is contained in:
parent
d09aca4175
commit
f463d9da76
5
Build.sh
5
Build.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.680 2015/07/05 15:45:16 tg Exp $'
|
srcversion='$MirOS: src/bin/mksh/Build.sh,v 1.681 2015/07/06 17:48:28 tg Exp $'
|
||||||
#-
|
#-
|
||||||
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
||||||
# 2011, 2012, 2013, 2014, 2015
|
# 2011, 2012, 2013, 2014, 2015
|
||||||
@ -2645,9 +2645,6 @@ MKSH_NOPROSPECTOFWORK disable jobs, co-processes, etc. (do not use)
|
|||||||
MKSH_NOPWNAM skip PAM calls, for -static on glibc or Solaris
|
MKSH_NOPWNAM skip PAM calls, for -static on glibc or Solaris
|
||||||
MKSH_NO_CMDLINE_EDITING disable command line editing code entirely
|
MKSH_NO_CMDLINE_EDITING disable command line editing code entirely
|
||||||
MKSH_NO_DEPRECATED_WARNING omit warning when deprecated stuff is run
|
MKSH_NO_DEPRECATED_WARNING omit warning when deprecated stuff is run
|
||||||
MKSH_NO_EXTERNAL_CAT omit hack to skip cat builtin when flags passed
|
|
||||||
MKSH_NO_EXTERNAL_REALPATH same for realpath builtin
|
|
||||||
MKSH_NO_EXTERNAL_RENAME same for rename builtin
|
|
||||||
MKSH_NO_LIMITS omit ulimit code
|
MKSH_NO_LIMITS omit ulimit code
|
||||||
MKSH_NO_SIGSETJMP define if sigsetjmp is broken or not available
|
MKSH_NO_SIGSETJMP define if sigsetjmp is broken or not available
|
||||||
MKSH_NO_SIGSUSPEND use sigprocmask+pause instead of sigsuspend
|
MKSH_NO_SIGSUSPEND use sigprocmask+pause instead of sigsuspend
|
||||||
|
20
check.t
20
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.698 2015/07/05 19:37:11 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.699 2015/07/06 17:48:29 tg Exp $
|
||||||
# -*- mode: sh -*-
|
# -*- mode: sh -*-
|
||||||
#-
|
#-
|
||||||
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
# 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
|
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R51 2015/07/05
|
@(#)MIRBSD KSH R51 2015/07/06
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -39,7 +39,7 @@ name: KSH_VERSION
|
|||||||
category: shell:legacy-no
|
category: shell:legacy-no
|
||||||
---
|
---
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)LEGACY KSH R51 2015/07/05
|
@(#)LEGACY KSH R51 2015/07/06
|
||||||
description:
|
description:
|
||||||
Check version of legacy shell.
|
Check version of legacy shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -8533,7 +8533,7 @@ description:
|
|||||||
Ensure concatenating behaviour matches other shells
|
Ensure concatenating behaviour matches other shells
|
||||||
stdin:
|
stdin:
|
||||||
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
|
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
|
||||||
#showargs 0 ""$@
|
showargs 0 ""$@
|
||||||
x=; showargs 1 "$x"$@
|
x=; showargs 1 "$x"$@
|
||||||
set A; showargs 2 "${@:+}"
|
set A; showargs 2 "${@:+}"
|
||||||
n() { echo "$#"; }
|
n() { echo "$#"; }
|
||||||
@ -8553,6 +8553,7 @@ stdin:
|
|||||||
n "$@"
|
n "$@"
|
||||||
n "$@""$e"
|
n "$@""$e"
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
|
<0> <> .
|
||||||
<1> <> .
|
<1> <> .
|
||||||
<2> <> .
|
<2> <> .
|
||||||
2
|
2
|
||||||
@ -8568,17 +8569,6 @@ expected-stdout:
|
|||||||
0
|
0
|
||||||
1
|
1
|
||||||
---
|
---
|
||||||
name: varexpand-null-3a
|
|
||||||
description:
|
|
||||||
Ensure concatenating behaviour matches other shells
|
|
||||||
(currently broken cases)
|
|
||||||
expected-fail: yes
|
|
||||||
stdin:
|
|
||||||
showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
|
|
||||||
showargs 0 ""$@
|
|
||||||
expected-stdout:
|
|
||||||
<0> <> .
|
|
||||||
---
|
|
||||||
name: print-funny-chars
|
name: print-funny-chars
|
||||||
description:
|
description:
|
||||||
Check print builtin's capability to output designated characters
|
Check print builtin's capability to output designated characters
|
||||||
|
43
exec.c
43
exec.c
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.154 2015/07/05 15:45:17 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.155 2015/07/06 17:48:31 tg Exp $");
|
||||||
|
|
||||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||||
@ -551,6 +551,8 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
|||||||
}
|
}
|
||||||
if ((tp = findcom(cp, FC_BI)) == NULL)
|
if ((tp = findcom(cp, FC_BI)) == NULL)
|
||||||
errorf("%s: %s: %s", Tbuiltin, cp, "not a builtin");
|
errorf("%s: %s: %s", Tbuiltin, cp, "not a builtin");
|
||||||
|
if (tp->type == CSHELL && tp->val.f == c_cat)
|
||||||
|
break;
|
||||||
continue;
|
continue;
|
||||||
} else if (tp->val.f == c_exec) {
|
} else if (tp->val.f == c_exec) {
|
||||||
if (ap[1] == NULL)
|
if (ap[1] == NULL)
|
||||||
@ -607,30 +609,19 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
|||||||
subst_exstat = 0;
|
subst_exstat = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if !defined(MKSH_NO_EXTERNAL_CAT) || \
|
} else if (tp->val.f == c_cat) {
|
||||||
!defined(MKSH_NO_EXTERNAL_REALPATH) || \
|
|
||||||
!defined(MKSH_NO_EXTERNAL_RENAME)
|
|
||||||
} else if (
|
|
||||||
#ifndef MKSH_NO_EXTERNAL_CAT
|
|
||||||
tp->val.f == c_cat ||
|
|
||||||
#endif
|
|
||||||
#ifndef MKSH_NO_EXTERNAL_REALPATH
|
|
||||||
tp->val.f == c_realpath ||
|
|
||||||
#endif
|
|
||||||
#ifndef MKSH_NO_EXTERNAL_RENAME
|
|
||||||
tp->val.f == c_rename ||
|
|
||||||
#endif
|
|
||||||
0) {
|
|
||||||
/* if we have any flags, do not use the builtin */
|
/* if we have any flags, do not use the builtin */
|
||||||
if (ap[1] && ap[1][0] == '-' && ap[1][1] != '\0' &&
|
if (ap[1] && ap[1][0] == '-' && ap[1][1] != '\0' &&
|
||||||
/* argument, begins with -, is not - or -- */
|
/* argument, begins with -, is not - or -- */
|
||||||
(ap[1][1] != '-' || ap[1][2] != '\0'))
|
(ap[1][1] != '-' || ap[1][2] != '\0')) {
|
||||||
/* don't look for builtins or functions */
|
struct tbl *ext_cat;
|
||||||
fcflags = FC_PATH;
|
|
||||||
else
|
ext_cat = findcom(Tcat, FC_PATH | FC_FUNC);
|
||||||
/* go on, use the builtin */
|
if (ext_cat && (ext_cat->type != CTALIAS ||
|
||||||
break;
|
(ext_cat->flag & ISSET)))
|
||||||
#endif
|
tp = ext_cat;
|
||||||
|
}
|
||||||
|
break;
|
||||||
} else if (tp->val.f == c_trap) {
|
} else if (tp->val.f == c_trap) {
|
||||||
t->u.evalflags &= ~DOTCOMEXEC;
|
t->u.evalflags &= ~DOTCOMEXEC;
|
||||||
break;
|
break;
|
||||||
@ -710,6 +701,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
|||||||
|
|
||||||
/* shell built-in */
|
/* shell built-in */
|
||||||
case CSHELL:
|
case CSHELL:
|
||||||
|
do_call_builtin:
|
||||||
rv = call_builtin(tp, (const char **)ap, null, resetspec);
|
rv = call_builtin(tp, (const char **)ap, null, resetspec);
|
||||||
if (resetspec && tp->val.f == c_shift) {
|
if (resetspec && tp->val.f == c_shift) {
|
||||||
l_expand->argc = l_assign->argc;
|
l_expand->argc = l_assign->argc;
|
||||||
@ -734,6 +726,11 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (include(tp->u.fpath, 0, NULL, false) < 0) {
|
if (include(tp->u.fpath, 0, NULL, false) < 0) {
|
||||||
|
if (!strcmp(cp, Tcat)) {
|
||||||
|
no_cat_in_FPATH:
|
||||||
|
tp = findcom(Tcat, FC_BI);
|
||||||
|
goto do_call_builtin;
|
||||||
|
}
|
||||||
warningf(true, "%s: %s %s %s: %s", cp,
|
warningf(true, "%s: %s %s %s: %s", cp,
|
||||||
"can't open", "function definition file",
|
"can't open", "function definition file",
|
||||||
tp->u.fpath, cstrerror(errno));
|
tp->u.fpath, cstrerror(errno));
|
||||||
@ -742,6 +739,8 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
|||||||
}
|
}
|
||||||
if (!(ftp = findfunc(cp, hash(cp), false)) ||
|
if (!(ftp = findfunc(cp, hash(cp), false)) ||
|
||||||
!(ftp->flag & ISSET)) {
|
!(ftp->flag & ISSET)) {
|
||||||
|
if (!strcmp(cp, Tcat))
|
||||||
|
goto no_cat_in_FPATH;
|
||||||
warningf(true, "%s: %s %s", cp,
|
warningf(true, "%s: %s %s", cp,
|
||||||
"function not defined by", tp->u.fpath);
|
"function not defined by", tp->u.fpath);
|
||||||
rv = 127;
|
rv = 127;
|
||||||
|
4
funcs.c
4
funcs.c
@ -38,7 +38,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.276 2015/07/05 19:37:14 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.277 2015/07/06 17:48:32 tg Exp $");
|
||||||
|
|
||||||
#if HAVE_KILLPG
|
#if HAVE_KILLPG
|
||||||
/*
|
/*
|
||||||
@ -99,7 +99,7 @@ const struct builtin mkshbuiltins[] = {
|
|||||||
{Talias, c_alias},
|
{Talias, c_alias},
|
||||||
{"*=break", c_brkcont},
|
{"*=break", c_brkcont},
|
||||||
{Tgbuiltin, c_builtin},
|
{Tgbuiltin, c_builtin},
|
||||||
{"cat", c_cat},
|
{Tcat, c_cat},
|
||||||
{"cd", c_cd},
|
{"cd", c_cd},
|
||||||
/* dash compatibility hack */
|
/* dash compatibility hack */
|
||||||
{"chdir", c_cd},
|
{"chdir", c_cd},
|
||||||
|
4
main.c
4
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.294 2015/07/05 19:37:16 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.295 2015/07/06 17:48:34 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ static const char *initcoms[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
/* this is what AT&T ksh seems to track, with the addition of emacs */
|
/* this is what AT&T ksh seems to track, with the addition of emacs */
|
||||||
Talias, "-tU",
|
Talias, "-tU",
|
||||||
"cat", "cc", "chmod", "cp", "date", "ed", "emacs", "grep", "ls",
|
Tcat, "cc", "chmod", "cp", "date", "ed", "emacs", "grep", "ls",
|
||||||
"make", "mv", "pr", "rm", "sed", "sh", "vi", "who", NULL,
|
"make", "mv", "pr", "rm", "sed", "sh", "vi", "who", NULL,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
23
mksh.1
23
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.372 2015/07/05 19:37:17 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.373 2015/07/06 17:48:35 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
.\" $OpenBSD: ksh.1,v 1.160 2015/07/04 13:27:04 feinerer Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
|
||||||
@ -74,7 +74,7 @@
|
|||||||
.\" with -mandoc, it might implement .Mx itself, but we want to
|
.\" with -mandoc, it might implement .Mx itself, but we want to
|
||||||
.\" use our own definition. And .Dd must come *first*, always.
|
.\" use our own definition. And .Dd must come *first*, always.
|
||||||
.\"
|
.\"
|
||||||
.Dd $Mdocdate: July 5 2015 $
|
.Dd $Mdocdate: July 6 2015 $
|
||||||
.\"
|
.\"
|
||||||
.\" Check which macro package we use, and do other -mdoc setup.
|
.\" Check which macro package we use, and do other -mdoc setup.
|
||||||
.\"
|
.\"
|
||||||
@ -3161,15 +3161,13 @@ If a
|
|||||||
is a single dash
|
is a single dash
|
||||||
.Pq Sq -
|
.Pq Sq -
|
||||||
or absent, read from standard input.
|
or absent, read from standard input.
|
||||||
Unless compiled with
|
|
||||||
.Dv MKSH_NO_EXTERNAL_CAT ,
|
|
||||||
if any options are given, an external
|
|
||||||
.Xr cat 1
|
|
||||||
utility is invoked instead if called from the shell.
|
|
||||||
For direct builtin calls, the
|
For direct builtin calls, the
|
||||||
.Tn POSIX
|
.Tn POSIX
|
||||||
.Fl u
|
.Fl u
|
||||||
option is supported as a no-op.
|
option is supported as a no-op.
|
||||||
|
For calls from shell, if any options are given, an external
|
||||||
|
.Xr cat 1
|
||||||
|
utility is preferred over the builtin.
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic cd
|
.Ic cd
|
||||||
@ -3958,12 +3956,6 @@ it's also checked for existence and whether it is a directory; otherwise,
|
|||||||
returns 0 if the pathname either exists or can be created immediately,
|
returns 0 if the pathname either exists or can be created immediately,
|
||||||
i.e. all but the last component exist and are directories.
|
i.e. all but the last component exist and are directories.
|
||||||
.Pp
|
.Pp
|
||||||
Unless compiled with
|
|
||||||
.Dv MKSH_NO_EXTERNAL_REALPATH ,
|
|
||||||
if any options are given and this is not a direct builtin call, an external
|
|
||||||
.Xr realpath 1
|
|
||||||
utility is invoked instead.
|
|
||||||
.Pp
|
|
||||||
.It Xo
|
.It Xo
|
||||||
.Ic rename
|
.Ic rename
|
||||||
.Op Fl \-
|
.Op Fl \-
|
||||||
@ -3978,11 +3970,6 @@ This builtin is intended for emergency situations where
|
|||||||
.Pa /bin/mv
|
.Pa /bin/mv
|
||||||
becomes unusable, and directly calls
|
becomes unusable, and directly calls
|
||||||
.Xr rename 2 .
|
.Xr rename 2 .
|
||||||
Unless compiled with
|
|
||||||
.Dv MKSH_NO_EXTERNAL_RENAME ,
|
|
||||||
if any options are given and this is not a direct builtin call, an external
|
|
||||||
.Xr rename 1
|
|
||||||
utility is invoked instead.
|
|
||||||
.Pp
|
.Pp
|
||||||
.It Ic return Op Ar status
|
.It Ic return Op Ar status
|
||||||
Returns from a function or
|
Returns from a function or
|
||||||
|
5
sh.h
5
sh.h
@ -169,9 +169,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.733 2015/07/05 19:37:18 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.734 2015/07/06 17:48:37 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R51 2015/07/05"
|
#define MKSH_VERSION "R51 2015/07/06"
|
||||||
|
|
||||||
/* arithmetic types: C implementation */
|
/* arithmetic types: C implementation */
|
||||||
#if !HAVE_CAN_INTTYPES
|
#if !HAVE_CAN_INTTYPES
|
||||||
@ -821,6 +821,7 @@ EXTERN const char T_typeset[] E_INIT("=typeset");
|
|||||||
#define Ttypeset (T_typeset + 1) /* "typeset" */
|
#define Ttypeset (T_typeset + 1) /* "typeset" */
|
||||||
EXTERN const char Talias[] E_INIT("alias");
|
EXTERN const char Talias[] E_INIT("alias");
|
||||||
EXTERN const char Tunalias[] E_INIT("unalias");
|
EXTERN const char Tunalias[] E_INIT("unalias");
|
||||||
|
EXTERN const char Tcat[] E_INIT("cat");
|
||||||
EXTERN const char Tsgset[] E_INIT("*=set");
|
EXTERN const char Tsgset[] E_INIT("*=set");
|
||||||
#define Tset (Tsgset + 2) /* "set" */
|
#define Tset (Tsgset + 2) /* "set" */
|
||||||
EXTERN const char Tsgexport[] E_INIT("*=export");
|
EXTERN const char Tsgexport[] E_INIT("*=export");
|
||||||
|
Loading…
Reference in New Issue
Block a user