commit: be846cacd9a75c5266da25fa11540a0643007c1f
parent: 99e90789844296e5549b25343253cfa35b6f0b0d
author: Brian Callahan <bcallah@openbsd.org>
date: Sat, 19 May 2018 22:34:52 -0400
type is now a shell built-in instead of an alias
6 files changed, 82 insertions(+), 53 deletions(-)
diff --git a/CVS/Entries b/CVS/Entries
@@ -1,46 +1,46 @@
/config.h/1.19/Tue Jan 16 02:21:56 2018//
/history.c/1.80/Tue Jan 16 02:21:56 2018//
/emacs.c/1.84/Result of merge//
-/main.c/1.91/Result of merge//
-/CONTRIBUTORS/1.10/Thu May 3 01:58:43 2018//
-/LEGAL/1.2/Thu May 3 01:58:43 2018//
-/Makefile/1.38/Thu May 3 01:58:49 2018//
-/NOTES/1.16/Thu May 3 01:58:43 2018//
-/PROJECTS/1.9/Thu May 3 01:58:43 2018//
-/README/1.16/Thu May 3 01:58:49 2018//
-/alloc.c/1.19/Thu May 3 01:58:43 2018//
-/c_ksh.c/1.60/Thu May 3 01:58:43 2018//
-/c_sh.c/1.63/Thu May 3 01:58:43 2018//
-/c_test.c/1.25/Thu May 3 01:58:43 2018//
-/c_test.h/1.4/Thu May 3 01:58:43 2018//
-/c_ulimit.c/1.28/Thu May 3 01:58:43 2018//
-/edit.c/1.65/Thu May 3 01:58:43 2018//
-/edit.h/1.11/Thu May 3 01:58:43 2018//
-/eval.c/1.60/Thu May 3 01:58:43 2018//
-/exec.c/1.73/Thu May 3 01:58:43 2018//
-/expand.h/1.15/Thu May 3 01:58:43 2018//
-/expr.c/1.33/Thu May 3 01:58:43 2018//
-/io.c/1.36/Thu May 3 01:58:43 2018//
-/jobs.c/1.60/Thu May 3 01:58:43 2018//
-/ksh.1/1.198/Thu May 3 01:58:43 2018//
-/lex.c/1.78/Thu May 3 01:58:43 2018//
-/lex.h/1.21/Thu May 3 01:58:43 2018//
-/mail.c/1.23/Thu May 3 01:58:43 2018//
-/misc.c/1.70/Thu May 3 01:58:43 2018//
-/path.c/1.22/Thu May 3 01:58:43 2018//
-/sh.1/1.148/Thu May 3 01:58:43 2018//
-/sh.h/1.72/Thu May 3 01:58:43 2018//
-/shf.c/1.33/Thu May 3 01:58:43 2018//
-/shf.h/1.8/Thu May 3 01:58:43 2018//
-/syn.c/1.39/Thu May 3 01:58:49 2018//
-/table.c/1.25/Thu May 3 01:58:43 2018//
-/table.h/1.14/Thu May 3 01:58:43 2018//
-/trap.c/1.32/Thu May 3 01:58:43 2018//
-/tree.c/1.34/Thu May 3 01:58:43 2018//
-/tree.h/1.12/Thu May 3 01:58:43 2018//
-/tty.c/1.17/Thu May 3 01:58:43 2018//
-/tty.h/1.6/Thu May 3 01:58:43 2018//
-/var.c/1.68/Thu May 3 01:58:43 2018//
-/version.c/1.12/Thu May 3 01:58:43 2018//
-/vi.c/1.56/Thu May 3 01:58:43 2018//
+/CONTRIBUTORS/1.10/Sun May 20 02:33:18 2018//
+/LEGAL/1.2/Sun May 20 02:33:18 2018//
+/Makefile/1.38/Sun May 20 02:33:24 2018//
+/NOTES/1.16/Sun May 20 02:33:18 2018//
+/PROJECTS/1.9/Sun May 20 02:33:18 2018//
+/README/1.16/Sun May 20 02:33:24 2018//
+/alloc.c/1.19/Sun May 20 02:33:18 2018//
+/c_ksh.c/1.61/Sun May 20 02:33:24 2018//
+/c_sh.c/1.63/Sun May 20 02:33:18 2018//
+/c_test.c/1.25/Sun May 20 02:33:18 2018//
+/c_test.h/1.4/Sun May 20 02:33:18 2018//
+/c_ulimit.c/1.28/Sun May 20 02:33:18 2018//
+/edit.c/1.65/Sun May 20 02:33:18 2018//
+/edit.h/1.11/Sun May 20 02:33:18 2018//
+/eval.c/1.60/Sun May 20 02:33:18 2018//
+/exec.c/1.73/Sun May 20 02:33:18 2018//
+/expand.h/1.15/Sun May 20 02:33:18 2018//
+/expr.c/1.33/Sun May 20 02:33:18 2018//
+/io.c/1.36/Sun May 20 02:33:18 2018//
+/jobs.c/1.60/Sun May 20 02:33:18 2018//
+/ksh.1/1.199/Sun May 20 02:33:24 2018//
+/lex.c/1.78/Sun May 20 02:33:18 2018//
+/lex.h/1.21/Sun May 20 02:33:18 2018//
+/mail.c/1.23/Sun May 20 02:33:18 2018//
+/main.c/1.92/Result of merge//
+/misc.c/1.70/Sun May 20 02:33:18 2018//
+/path.c/1.22/Sun May 20 02:33:18 2018//
+/sh.1/1.148/Sun May 20 02:33:18 2018//
+/sh.h/1.73/Sun May 20 02:33:24 2018//
+/shf.c/1.33/Sun May 20 02:33:18 2018//
+/shf.h/1.8/Sun May 20 02:33:18 2018//
+/syn.c/1.39/Sun May 20 02:33:19 2018//
+/table.c/1.25/Sun May 20 02:33:19 2018//
+/table.h/1.14/Sun May 20 02:33:19 2018//
+/trap.c/1.32/Sun May 20 02:33:19 2018//
+/tree.c/1.34/Sun May 20 02:33:19 2018//
+/tree.h/1.12/Sun May 20 02:33:19 2018//
+/tty.c/1.17/Sun May 20 02:33:19 2018//
+/tty.h/1.6/Sun May 20 02:33:19 2018//
+/var.c/1.68/Sun May 20 02:33:19 2018//
+/version.c/1.12/Sun May 20 02:33:19 2018//
+/vi.c/1.56/Sun May 20 02:33:19 2018//
D
diff --git a/CVS/Entries.Log b/CVS/Entries.Log
@@ -0,0 +1,2 @@
+A D/tests////
+R D/tests////
diff --git a/c_ksh.c b/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.60 2018/04/09 17:53:36 tobias Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.61 2018/05/18 13:25:20 benno Exp $ */
/*
* built-in Korn commands: c_*
@@ -410,9 +410,26 @@ c_whence(char **wp)
int pflag = 0, vflag = 0, Vflag = 0;
int ret = 0;
int optc;
- int iam_whence = wp[0][0] == 'w';
+ int iam_whence;
int fcflags;
- const char *options = iam_whence ? "pv" : "pvV";
+ const char *options;
+
+ switch (wp[0][0]) {
+ case 'c': /* command */
+ iam_whence = 0;
+ options = "pvV";
+ break;
+ case 't': /* type */
+ vflag = 1;
+ /* FALLTHROUGH */
+ case 'w': /* whence */
+ iam_whence = 1;
+ options = "pv";
+ break;
+ default:
+ bi_errorf("builtin not handled by %s", __func__);
+ return 1;
+ }
while ((optc = ksh_getopt(wp, &builtin_opt, options)) != -1)
switch (optc) {
@@ -430,7 +447,6 @@ c_whence(char **wp)
}
wp += builtin_opt.optind;
-
fcflags = FC_BI | FC_PATH | FC_FUNC;
if (!iam_whence) {
/* Note that -p on its own is dealt with in comexec() */
@@ -530,6 +546,13 @@ c_command(char **wp)
return c_whence(wp);
}
+int
+c_type(char **wp)
+{
+ /* Let c_whence do the work. type = command -V = whence -v */
+ return c_whence(wp);
+}
+
/* typeset, export, and readonly */
int
c_typeset(char **wp)
@@ -1392,6 +1415,7 @@ const struct builtin kshbuiltins [] = {
{"print", c_print},
{"pwd", c_pwd},
{"*=readonly", c_typeset},
+ {"type", c_type},
{"=typeset", c_typeset},
{"+unalias", c_unalias},
{"whence", c_whence},
diff --git a/ksh.1 b/ksh.1
@@ -1,8 +1,8 @@
-.\" $OpenBSD: ksh.1,v 1.198 2018/02/06 15:13:32 schwarze Exp $
+.\" $OpenBSD: ksh.1,v 1.199 2018/05/18 13:25:20 benno Exp $
.\"
.\" Public Domain
.\"
-.Dd $Mdocdate: February 6 2018 $
+.Dd $Mdocdate: May 18 2018 $
.Dt KSH 1
.Os
.Sh NAME
@@ -858,8 +858,6 @@ The following command aliases are defined automatically by the shell:
.Ic r Ns ='fc -s'
.It
.Ic stop Ns ='kill -STOP'
-.It
-.Ic type Ns ='whence -v'
.El
.Pp
Tracked aliases allow the shell to remember where it found a particular
@@ -4075,6 +4073,11 @@ traps in functions are not yet implemented.
.It Ic true
A command that exits with a zero value.
.Pp
+.It Ic type
+Short form of
+.Ic whence Fl v
+(see below).
+.Pp
.It Xo
.Ic typeset
.Oo
diff --git a/main.c b/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.91 2018/04/09 17:53:36 tobias Exp $ */
+/* $OpenBSD: main.c,v 1.92 2018/05/18 13:25:20 benno Exp $ */
/*
* startup, main loop, environments and error handling
@@ -88,7 +88,6 @@ static const char *initcoms [] = {
"alias",
/* Standard ksh aliases */
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
- "type=whence -v",
"stop=kill -STOP",
"autoload=typeset -fu",
"functions=typeset -f",
diff --git a/sh.h b/sh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh.h,v 1.72 2018/04/09 17:53:36 tobias Exp $ */
+/* $OpenBSD: sh.h,v 1.73 2018/05/18 13:25:20 benno Exp $ */
/*
* Public Domain Bourne/Korn shell
@@ -382,6 +382,7 @@ int c_pwd(char **);
int c_print(char **);
int c_whence(char **);
int c_command(char **);
+int c_type(char **);
int c_typeset(char **);
int c_alias(char **);
int c_unalias(char **);