Implement the “source” command, as requested by some and agreed bsiegert@

In contrast to AT&T ksh93, its semantics are like GNU bash in that it ap-
pends the current working directory to the search path; it is implemented
as a shell alias instead of enhancing funcs.c:shbuiltins[] like in ksh93.
This commit is contained in:
tg 2007-08-13 19:39:21 +00:00
parent 7381c6c274
commit f684b0ceb1
4 changed files with 27 additions and 7 deletions

View File

@ -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'

3
main.c
View File

@ -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 */

22
mksh.1
View File

@ -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 ,

4
sh.h
View File

@ -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>