From f684b0ceb1f7bdbe828af833fa1341865cb1c168 Mon Sep 17 00:00:00 2001
From: tg <tg@mirbsd.org>
Date: Mon, 13 Aug 2007 19:39:21 +0000
Subject: [PATCH] =?UTF-8?q?Implement=20the=20=E2=80=9Csource=E2=80=9D=20co?=
 =?UTF-8?q?mmand,=20as=20requested=20by=20some=20and=20agreed=20bsiegert@?=
 =?UTF-8?q?=20In=20contrast=20to=20AT&T=20ksh93,=20its=20semantics=20are?=
 =?UTF-8?q?=20like=20GNU=20bash=20in=20that=20it=20ap-=20pends=20the=20cur?=
 =?UTF-8?q?rent=20working=20directory=20to=20the=20search=20path;=20it=20i?=
 =?UTF-8?q?s=20implemented=20as=20a=20shell=20alias=20instead=20of=20enhan?=
 =?UTF-8?q?cing=20funcs.c:shbuiltins[]=20like=20in=20ksh93.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 check.t |  5 +++--
 main.c  |  3 ++-
 mksh.1  | 22 ++++++++++++++++++++--
 sh.h    |  4 ++--
 4 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/check.t b/check.t
index 86333f5..3f58dbf 100644
--- a/check.t
+++ b/check.t
@@ -1,4 +1,4 @@
-# $MirOS: src/bin/mksh/check.t,v 1.133 2007/08/12 13:42:20 tg Exp $
+# $MirOS: src/bin/mksh/check.t,v 1.134 2007/08/13 19:39:19 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 $
@@ -7,7 +7,7 @@
 # http://www.research.att.com/~gsf/public/ifs.sh
 
 expected-stdout:
-	@(#)MIRBSD KSH R30 2007/08/12
+	@(#)MIRBSD KSH R30 2007/08/13
 description:
 	Check version of shell.
 category: pdksh
@@ -4002,6 +4002,7 @@ expected-stdout:
 	login='exec login'
 	nohup='nohup '
 	r='fc -e -'
+	source='PATH=$PATH:. command .'
 	stop='kill -STOP'
 	suspend='kill -STOP $$'
 	type='whence -v'
diff --git a/main.c b/main.c
index 7608250..440790e 100644
--- a/main.c
+++ b/main.c
@@ -13,7 +13,7 @@
 #include <locale.h>
 #endif
 
-__RCSID("$MirOS: src/bin/mksh/main.c,v 1.85 2007/08/12 13:42:21 tg Exp $");
+__RCSID("$MirOS: src/bin/mksh/main.c,v 1.86 2007/08/13 19:39:19 tg Exp $");
 
 extern char **environ;
 
@@ -49,6 +49,7 @@ static const char *initcoms_korn[] = {
 	"history=fc -l",
 	"nohup=nohup ",
 	"r=fc -e -",
+	"source=PATH=$PATH:. command .",
 	"login=exec login",
 	NULL,
 	 /* this is what at&t ksh seems to track, with the addition of emacs */
diff --git a/mksh.1 b/mksh.1
index e878ef2..329a578 100644
--- a/mksh.1
+++ b/mksh.1
@@ -1,4 +1,4 @@
-.\" $MirOS: src/bin/mksh/mksh.1,v 1.95 2007/08/12 14:01:38 tg Exp $
+.\" $MirOS: src/bin/mksh/mksh.1,v 1.96 2007/08/13 19:39:20 tg Exp $
 .\" $OpenBSD: ksh.1,v 1.120 2007/05/31 20:47:44 otto Exp $
 .\"
 .Dd August 12, 2007
@@ -2379,6 +2379,9 @@ The following describes the special and regular built-in commands:
 .Pp
 .Bl -tag -width Ds -compact
 .It Ic \&. Ar file Op Ar arg ...
+This is called the
+.Dq dot
+command.
 Execute the commands in
 .Ar file
 in the current environment.
@@ -3487,6 +3490,21 @@ etc.
 .Ar number
 defaults to 1.
 .Pp
+.It Ic source Ar file Op Ar arg ...
+Like
+.Ic \&. Po Do dot Dc Pc ,
+except that the current working directory is appended to the
+.Ev PATH
+in GNU
+.Nm bash
+and
+.Nm mksh .
+In
+.Nm ksh93
+and
+.Nm mksh ,
+this is implemented as a shell alias instead of a builtin.
+.Pp
 .It Ic test Ar expression
 .It Ic \&[ Ar expression Ic \&]
 .Ic test
@@ -5352,7 +5370,7 @@ and many other persons, and is currently maintained by
 .An Thorsten Glaser Aq tg@mirbsd.de .
 .Sh BUGS
 This document attempts to describe
-.Nm mksh R30b
+.Nm mksh R31
 and up,
 compiled without any options impacting functionality, such as
 .Dv MKSH_SMALL ,
diff --git a/sh.h b/sh.h
index ff4abc9..f586e07 100644
--- a/sh.h
+++ b/sh.h
@@ -8,8 +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.169 2007/08/12 13:52:03 tg Exp $"
-#define MKSH_VERSION "R30 2007/08/12"
+#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.170 2007/08/13 19:39:21 tg Exp $"
+#define MKSH_VERSION "R30 2007/08/13"
 
 #if HAVE_SYS_PARAM_H
 #include <sys/param.h>