now we don’t need more special FPOSIX behaviour any more

This commit is contained in:
tg 2008-02-25 00:58:26 +00:00
parent 8c86fedc2d
commit 5468e6ee12
3 changed files with 68 additions and 36 deletions

59
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.145 2008/02/24 22:12:36 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.146 2008/02/25 00:58:24 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 $
@ -4019,10 +4019,11 @@ expected-stdout:
suspend='kill -STOP $$' suspend='kill -STOP $$'
type='whence -v' type='whence -v'
--- ---
name: aliases-2 name: aliases-2a
description: description:
Check if set -o posix disables built-in aliases (except a few) Check if set -o posix disables built-in aliases (except a few)
category: pdksh #category: pdksh
category: disabled
arguments: !-o!posix! arguments: !-o!posix!
stdin: stdin:
alias alias
@ -4031,10 +4032,11 @@ expected-stdout:
integer='typeset -i' integer='typeset -i'
local=typeset local=typeset
--- ---
name: aliases-3 name: aliases-3a
description: description:
Check if running as sh disables built-in aliases (except a few) Check if running as sh disables built-in aliases (except a few)
category: pdksh #category: pdksh
category: disabled
arguments: !-o!posix! arguments: !-o!posix!
stdin: stdin:
cp "$0" sh cp "$0" sh
@ -4044,6 +4046,53 @@ expected-stdout:
integer='typeset -i' integer='typeset -i'
local=typeset local=typeset
--- ---
name: aliases-2b
description:
Check if set -o posix does not influence built-in aliases
category: pdksh
arguments: !-o!posix!
stdin:
alias
typeset -f
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
stop='kill -STOP'
suspend='kill -STOP $$'
type='whence -v'
---
name: aliases-3b
description:
Check if running as sh does not influence built-in aliases
category: pdksh
arguments: !-o!posix!
stdin:
cp "$0" sh
./sh -c 'alias; typeset -f'
rm -f sh
expected-stdout:
autoload='typeset -fu'
functions='typeset -f'
hash='alias -t'
history='fc -l'
integer='typeset -i'
local=typeset
login='exec login'
nohup='nohup '
r='fc -e -'
source='PATH=$PATH:. command .'
stop='kill -STOP'
suspend='kill -STOP $$'
type='whence -v'
---
name: arrays-1 name: arrays-1
description: description:
Check if Korn Shell arrays work as expected Check if Korn Shell arrays work as expected

31
main.c
View File

@ -13,7 +13,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.89 2007/10/25 15:23:10 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.90 2008/02/25 00:58:26 tg Exp $");
extern char **environ; extern char **environ;
@ -35,10 +35,6 @@ static const char *initcoms[] = {
"typeset", "-i", "PPID", "OPTIND=1", NULL, "typeset", "-i", "PPID", "OPTIND=1", NULL,
"eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL, "eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
"alias", "integer=typeset -i", "local=typeset", NULL, "alias", "integer=typeset -i", "local=typeset", NULL,
NULL
};
static const char *initcoms_korn[] = {
"alias", "alias",
"hash=alias -t", /* not "alias -t --": hash -r needs to work */ "hash=alias -t", /* not "alias -t --": hash -r needs to work */
"type=whence -v", "type=whence -v",
@ -157,15 +153,6 @@ main(int argc, const char *argv[])
/* setstr can't fail here */ /* setstr can't fail here */
setstr(vp, def_path, KSH_RETURN_ERROR); setstr(vp, def_path, KSH_RETURN_ERROR);
/* Set FPOSIX if we're called as -sh or /bin/sh or so */
cc = kshname;
i = 0; argi = 0;
while (cc[i] != '\0')
if ((cc[i++] | 2) == '/')
argi = i;
if (((cc[argi] | 0x20) == 's') && ((cc[argi + 1] | 0x20) == 'h'))
Flag(FPOSIX) = 1;
/* Turn on nohup by default for now - will change to off /* Turn on nohup by default for now - will change to off
* by default once people are aware of its existence * by default once people are aware of its existence
* (at&t ksh does not have a nohup option - it always sends * (at&t ksh does not have a nohup option - it always sends
@ -186,6 +173,15 @@ main(int argc, const char *argv[])
Flag(FVITABCOMPLETE) = 1; Flag(FVITABCOMPLETE) = 1;
#endif #endif
/* Set FPOSIX if we're called as -sh or /bin/sh or so */
cc = kshname;
i = 0; argi = 0;
while (cc[i] != '\0')
if ((cc[i++] | 2) == '/')
argi = i;
if (((cc[argi] | 0x20) == 's') && ((cc[argi + 1] | 0x20) == 'h'))
change_flag(FPOSIX, OF_FIRSTTIME, 1);
/* import environment */ /* import environment */
if (environ != NULL) if (environ != NULL)
for (wp = (const char **)environ; *wp != NULL; wp++) for (wp = (const char **)environ; *wp != NULL; wp++)
@ -256,13 +252,6 @@ main(int argc, const char *argv[])
if (argi < 0) if (argi < 0)
exit(1); exit(1);
if (!Flag(FPOSIX))
for (wp = initcoms_korn; *wp != NULL; wp++) {
shcomexec(wp);
while (*wp != NULL)
wp++;
}
if (Flag(FCOMMAND)) { if (Flag(FCOMMAND)) {
s = pushs(SSTRING, ATEMP); s = pushs(SSTRING, ATEMP);
if (!(s->start = s->str = argv[argi++])) if (!(s->start = s->str = argv[argi++]))

14
mksh.1
View File

@ -1,7 +1,7 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.105 2008/02/24 15:48:43 tg Exp $ .\" $MirOS: src/bin/mksh/mksh.1,v 1.106 2008/02/25 00:58:26 tg Exp $
.\" $OpenBSD: ksh.1,v 1.120 2007/05/31 20:47:44 otto Exp $ .\" $OpenBSD: ksh.1,v 1.120 2007/05/31 20:47:44 otto Exp $
.\" .\"
.Dd October 25, 2007 .Dd February 24, 2008
.Dt MKSH 1 .Dt MKSH 1
.Os MirBSD .Os MirBSD
.Sh NAME .Sh NAME
@ -818,13 +818,7 @@ The alias expansion process stops when a word that is not an alias is found,
when a quoted word is found, or when an alias word that is currently being when a quoted word is found, or when an alias word that is currently being
expanded is found. expanded is found.
.Pp .Pp
The following command aliases are defined automatically by the shell, unless The following command aliases are defined automatically by the shell:
.Fl o Ic posix
is set, in which case only
.Dq integer
and
.Dq local
are defined to support existing shell scripts:
.Bd -literal -offset indent .Bd -literal -offset indent
autoload='typeset -fu' autoload='typeset -fu'
functions='typeset -f' functions='typeset -f'
@ -5388,7 +5382,7 @@ and many other persons, and is currently maintained by
.An Thorsten Glaser Aq tg@mirbsd.de . .An Thorsten Glaser Aq tg@mirbsd.de .
.Sh BUGS .Sh BUGS
This document attempts to describe This document attempts to describe
.Nm mksh R32 .Nm mksh R33
and up, and up,
compiled without any options impacting functionality, such as compiled without any options impacting functionality, such as
.Dv MKSH_SMALL , .Dv MKSH_SMALL ,