From 56a8da33cf0f43e891b9ca0a8fb835e383944811 Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 17 Jul 2007 13:56:51 +0000 Subject: [PATCH] =?UTF-8?q?=E2=80=A2=20make=20the=20"if=20called=20as=20sh?= =?UTF-8?q?,=20set=20FPOSIX"=20not=20!SMALL-only=20=E2=80=A2=20bump=20to?= =?UTF-8?q?=20R30-gamma,=20feature=20freeze?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check.t | 6 +++--- main.c | 27 ++++++++------------------- sh.h | 4 ++-- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/check.t b/check.t index 2d9d22a..5ea125b 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.125 2007/07/06 11:54:34 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.126 2007/07/17 13:56:50 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 R29 2007/07/05 + @(#)MIRBSD KSH R30 2007/07/17 description: Check version of shell. category: pdksh @@ -4004,7 +4004,7 @@ expected-stdout: name: aliases-3 description: Check if running as sh disables built-in aliases (except a few) -category: pdksh,!smksh +category: pdksh arguments: !-o!posix! stdin: cp "$0" sh diff --git a/main.c b/main.c index 69ddd20..6b0ab81 100644 --- a/main.c +++ b/main.c @@ -13,7 +13,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.82 2007/07/01 21:10:29 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.83 2007/07/17 13:56:51 tg Exp $"); extern char **environ; @@ -63,12 +63,11 @@ static int initio_done; int main(int argc, const char *argv[]) { - int i; - int argi; + int argi, i; Source *s; struct block *l; int restricted, errexit; - const char **wp; + const char **wp, *cc; struct env env; pid_t ppid; struct tbl *vp; @@ -77,9 +76,6 @@ main(int argc, const char *argv[]) size_t k; char *cp; #endif -#if !defined(MKSH_SMALL) || HAVE_SETLOCALE_CTYPE - const char *cc; -#endif /* make sure argv[] is sane */ if (!*argv) { @@ -162,21 +158,14 @@ main(int argc, const char *argv[]) /* setstr can't fail here */ setstr(vp, def_path, KSH_RETURN_ERROR); -#ifndef MKSH_SMALL + /* Set FPOSIX if we're called as -sh or /bin/sh or so */ cc = kshname; - if (*cc == '-') - ++cc; - i = 0; + i = 0; argi = 0; while (cc[i] != '\0') - if (cc[i] == '/') { - cc += i + 1; - i = 0; - } else - ++i; - if ((cc[0] == 's' || cc[0] == 'S') && - (cc[1] == 'h' || cc[1] == 'H')) + if ((cc[i++] | 2) == '/') + argi = i; + if (((cc[argi] | 0x20) == 's') && ((cc[argi + 1] | 0x20) == 'h')) Flag(FPOSIX) = 1; -#endif /* Turn on nohup by default for now - will change to off * by default once people are aware of its existence diff --git a/sh.h b/sh.h index 93f2e39..fba8b89 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.156 2007/07/06 02:22:57 tg Exp $" -#define MKSH_VERSION "R29 2007/07/05" +#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.157 2007/07/17 13:56:49 tg Exp $" +#define MKSH_VERSION "R30 2007/07/17" #if HAVE_SYS_PARAM_H #include