diff --git a/exec.c b/exec.c index dc09e5f..e20c6bb 100644 --- a/exec.c +++ b/exec.c @@ -1,11 +1,11 @@ -/** $MirOS: src/bin/mksh/exec.c,v 1.6 2005/07/04 12:27:25 tg Exp $ */ +/** $MirOS: src/bin/mksh/exec.c,v 1.7 2005/07/04 12:34:22 tg Exp $ */ /* $OpenBSD: exec.c,v 1.41 2005/03/30 17:16:37 deraadt Exp $ */ #include "sh.h" #include #include -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.6 2005/07/04 12:27:25 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.7 2005/07/04 12:34:22 tg Exp $"); static int comexec(struct op *, struct tbl *volatile, char **, int volatile); @@ -398,7 +398,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags) * functions/dot scripts, but in interactive and script) - * perhaps save last arg here and set it in shell()?. */ - if (!Flag(FSH) && Flag(FTALKING) && *(lastp = ap)) { + if (Flag(FTALKING) && *(lastp = ap)) { while (*++lastp) ; /* setstr() can't fail here */ @@ -647,12 +647,10 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags) break; } - if (!Flag(FSH)) { - /* set $_ to programme's full path */ - /* setstr() can't fail here */ - setstr(typeset("_", LOCAL|EXPORT, 0, INTEGER, 0), - tp->val.s, KSH_RETURN_ERROR); - } + /* set $_ to programme's full path */ + /* setstr() can't fail here */ + setstr(typeset("_", LOCAL|EXPORT, 0, INTEGER, 0), + tp->val.s, KSH_RETURN_ERROR); if (flags&XEXEC) { j_exit(); diff --git a/funcs.c b/funcs.c index 0544bd2..9f5f2cb 100644 --- a/funcs.c +++ b/funcs.c @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/funcs.c,v 1.13 2005/07/04 12:27:26 tg Exp $ */ +/** $MirOS: src/bin/mksh/funcs.c,v 1.14 2005/07/04 12:34:22 tg Exp $ */ /* $OpenBSD: c_ksh.c,v 1.27 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: c_sh.c,v 1.29 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: c_test.c,v 1.17 2005/03/30 17:16:37 deraadt Exp $ */ @@ -13,7 +13,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.13 2005/07/04 12:27:26 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.14 2005/07/04 12:34:22 tg Exp $"); int c_cd(char **wp) @@ -2183,13 +2183,8 @@ c_exec(char **wp __attribute__((unused))) for (i = 0; i < NUFILE; i++) { if (e->savefd[i] > 0) close(e->savefd[i]); - /* - * For ksh keep anything > 2 private, - * for sh, let them be (POSIX says what - * happens is unspecified and the bourne shell - * keeps them open). - */ - if (!Flag(FSH) && i > 2 && e->savefd[i]) + /* For ksh keep anything > 2 private */ + if (i > 2 && e->savefd[i]) fcntl(i, F_SETFD, FD_CLOEXEC); } e->savefd = NULL; diff --git a/lex.c b/lex.c index a88b9b2..cc448a8 100644 --- a/lex.c +++ b/lex.c @@ -1,11 +1,11 @@ -/** $MirOS: src/bin/mksh/lex.c,v 1.5 2005/07/04 12:27:26 tg Exp $ */ +/** $MirOS: src/bin/mksh/lex.c,v 1.6 2005/07/04 12:34:23 tg Exp $ */ /* $OpenBSD: lex.c,v 1.36 2005/03/30 17:16:37 deraadt Exp $ */ #include "sh.h" #include #include -__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.5 2005/07/04 12:27:26 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.6 2005/07/04 12:34:23 tg Exp $"); /* Structure to keep track of the lexing state and the various pieces of info * needed for each particular state. */ @@ -677,13 +677,11 @@ Done: return c; case '(': /*)*/ - if (!Flag(FSH)) { - if ((c2 = getsc()) == '(') /*)*/ - /* XXX need to handle ((...); (...)) */ - c = MDPAREN; - else - ungetsc(c2); - } + if ((c2 = getsc()) == '(') /*)*/ + /* XXX need to handle ((...); (...)) */ + c = MDPAREN; + else + ungetsc(c2); return c; /*(*/ case ')': diff --git a/main.c b/main.c index 0cc5100..9f1bfab 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/main.c,v 1.18 2005/07/04 12:27:26 tg Exp $ */ +/** $MirOS: src/bin/mksh/main.c,v 1.19 2005/07/04 12:34:23 tg Exp $ */ /* $OpenBSD: main.c,v 1.38 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: tty.c,v 1.8 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: io.c,v 1.21 2005/03/30 17:16:37 deraadt Exp $ */ @@ -13,7 +13,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.18 2005/07/04 12:27:26 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.19 2005/07/04 12:34:23 tg Exp $"); const char ksh_version[] = "@(#)MIRBSD KSH R23 2005/07/04"; @@ -29,8 +29,7 @@ static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }"; static const char *initcoms[] = { "typeset", "-r", "KSH_VERSION", NULL, "typeset", "-x", "SHELL", "PATH", "HOME", NULL, - "typeset", "-i", "PGRP=0", "PPID", NULL, - "typeset", "-i", "OPTIND=1", NULL, + "typeset", "-i", "PPID", "OPTIND=1", NULL, "eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL, "alias", /* Standard ksh aliases */ @@ -156,11 +155,6 @@ main(int argc, char *argv[]) */ Flag(FBRACEEXPAND) = 1; - /* Check to see if we're /bin/sh. */ - if (!strcmp(&kshname[strlen(kshname) - 3], "/sh") || - !strcmp(kshname, "sh") || !strcmp(kshname, "-sh")) - Flag(FSH) = 1; - /* Set edit mode to emacs by default, may be overridden * by the environment or the user. Also, we want tab completion * on in vi by default. */ @@ -207,8 +201,7 @@ main(int argc, char *argv[]) #endif setint(global("PPID"), (long)ppid); /* setstr can't fail here */ - if (!Flag(FSH)) - setstr(global("KSH_VERSION"), ksh_version, KSH_RETURN_ERROR); + setstr(global("KSH_VERSION"), ksh_version, KSH_RETURN_ERROR); /* execute initialisation statements */ for (wp = (char **)initcoms; *wp != NULL; wp++) { diff --git a/misc.c b/misc.c index 988436d..7706ecd 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/misc.c,v 1.5 2005/07/04 12:27:27 tg Exp $ */ +/** $MirOS: src/bin/mksh/misc.c,v 1.6 2005/07/04 12:34:23 tg Exp $ */ /* $OpenBSD: misc.c,v 1.28 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: path.c,v 1.12 2005/03/30 17:16:37 deraadt Exp $ */ @@ -7,7 +7,7 @@ #include /* for MAXPATHLEN */ #include -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.5 2005/07/04 12:27:27 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.6 2005/07/04 12:34:23 tg Exp $"); short chtypes[UCHAR_MAX+1]; /* type bits for unsigned char */ @@ -252,7 +252,7 @@ change_flag(enum sh_flag f, int oldval; /* disabled functionality */ - if (f == FPOSIX) + if ((f == FPOSIX) || (f == FSH)) return; oldval = Flag(f); diff --git a/mksh.1 b/mksh.1 index f1f049b..8382435 100644 --- a/mksh.1 +++ b/mksh.1 @@ -1,4 +1,4 @@ -.\" $MirOS: src/bin/mksh/mksh.1,v 1.12 2005/07/04 12:27:27 tg Exp $ +.\" $MirOS: src/bin/mksh/mksh.1,v 1.13 2005/07/04 12:34:23 tg Exp $ .\" $OpenBSD: ksh.1,v 1.99 2005/05/25 16:52:06 jaredy Exp $ .\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $ .\" @@ -22,7 +22,7 @@ .. .Sh NAME .Nm mksh -.Nd MirBSD Korn/Bourne shell +.Nd MirBSD Korn shell .Sh SYNOPSIS .Nm .Bk -words @@ -1454,8 +1454,6 @@ An empty string resulting from a leading or trailing colon, or two adjacent colons, is treated as a .Sq \&. (the current directory). -.It Ev PGRP -The current process group (read-only). .It Ev PPID The process ID of the shell's parent (read-only). .It Ev PS1 @@ -2263,51 +2261,6 @@ trapped) will have their default effect in a function. The EXIT trap, if set in a function, will be executed after the function returns. .El -.Ss Strict Bourne shell mode -When the -.Ic sh -option is enabled (see the -.Ic set -command), -.Nm -will behave like -.Xr sh 1 -in the following ways: -.Bl -bullet -.It -The parameter -.Ic $_ -is not set to: -.Pp -.Bl -dash -compact -.It -the expanded alias' full programme path after entering commands -that are tracked aliases -.It -the last argument on the command line after entering external -commands -.El -.It -File descriptors are left untouched when executing -.Ic exec -with no arguments. -.It -Backslash-escaped special characters are not substituted in -.Ev PS1 . -.It -Sequences of -.Sq ((...)) -are not interpreted as arithmetic expressions. -.El -.Pp -This does not make -.Nm -a real bourne shell emulation, though. -Access to many enhanced features is still available, and -.Ql ^ -as synonym for -.Ql | -has probably not been in use since the 1980s anyway. .Ss Command execution After evaluation of command-line arguments, redirections, and parameter assignments, the type of command is determined: a special built-in, a @@ -3316,10 +3269,6 @@ commands above for more details. The shell is a restricted shell. This option can only be used when the shell is invoked. See above for a description of what this means. -.It Ic sh -Enable strict Bourne shell mode (see -.Sx Strict Bourne shell mode -above). .It Ic vi Enable .Xr vi 1 Ns -like @@ -5156,7 +5105,6 @@ Shell database. .Xr dup 2 , .Xr execve 2 , .Xr getgid 2 , -.Xr getpgrp 2 , .Xr getuid 2 , .Xr open 2 , .Xr pipe 2 , diff --git a/sh.h b/sh.h index a183f46..bedd011 100644 --- a/sh.h +++ b/sh.h @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/sh.h,v 1.13 2005/07/04 12:07:41 tg Exp $ */ +/** $MirOS: src/bin/mksh/sh.h,v 1.14 2005/07/04 12:34:24 tg Exp $ */ /* $OpenBSD: sh.h,v 1.27 2005/03/28 21:33:04 deraadt Exp $ */ /* $OpenBSD: shf.h,v 1.5 2005/03/30 17:16:37 deraadt Exp $ */ /* $OpenBSD: table.h,v 1.6 2004/12/18 20:55:52 millert Exp $ */ @@ -190,10 +190,10 @@ enum sh_flag { FNOTIFY, /* -b: asynchronous job completion notification */ FNOUNSET, /* -u: using an unset var is an error */ FPHYSICAL, /* -o physical: don't do logical cds/pwds */ - FPOSIX, /* -o posix: be posixly correct */ + FPOSIX, /* -o posix (disabled) */ FPRIVILEGED, /* -p: use suid_profile */ FRESTRICTED, /* -r: restricted shell */ - FSH, /* -o sh: favor sh behaviour */ + FSH, /* -o sh (disabled) */ FSTDIN, /* -s: (invocation) parse stdin */ FTRACKALL, /* -h: create tracked aliases for all commands */ FVERBOSE, /* -v: echo input */ @@ -204,7 +204,7 @@ enum sh_flag { FVIESCCOMPLETE, /* enable ESC as file name completion in command mode */ FXTRACE, /* -x: execution trace */ FTALKING_I, /* (internal): initial shell was interactive */ - FNFLAGS /* (place holder: how many flags are there) */ + FNFLAGS /* (place holder: how many flags are there) */ }; #define Flag(f) (shell_flags[(int) (f)]) @@ -626,13 +626,10 @@ extern const struct builtin shbuiltins [], kshbuiltins []; #define V_RANDOM 8 #define V_HISTSIZE 9 #define V_HISTFILE 10 -#define V_VISUAL 11 -#define V_EDITOR 12 #define V_COLUMNS 13 #define V_TMOUT 15 #define V_TMPDIR 16 #define V_LINENO 17 -#define V_PGRP 18 /* values for set_prompt() */ #define PS1 0 /* command */ diff --git a/var.c b/var.c index 0a5581e..f58efab 100644 --- a/var.c +++ b/var.c @@ -1,4 +1,4 @@ -/** $MirOS: src/bin/mksh/var.c,v 1.7 2005/07/04 12:07:41 tg Exp $ */ +/** $MirOS: src/bin/mksh/var.c,v 1.8 2005/07/04 12:34:24 tg Exp $ */ /* $OpenBSD: var.c,v 1.26 2005/03/30 17:16:37 deraadt Exp $ */ #include "sh.h" @@ -6,7 +6,7 @@ #include #include -__RCSID("$MirOS: src/bin/mksh/var.c,v 1.7 2005/07/04 12:07:41 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/var.c,v 1.8 2005/07/04 12:34:24 tg Exp $"); /* * Variables @@ -98,7 +98,6 @@ initvar(void) { "SECONDS", V_SECONDS }, { "TMOUT", V_TMOUT }, { "LINENO", V_LINENO }, - { "PGRP", V_PGRP }, { NULL, 0 } }; int i; @@ -934,11 +933,6 @@ getspec(struct tbl *vp) setint(vp, (long) current_lineno + user_lineno); vp->flag |= SPECIAL; break; - case V_PGRP: - vp->flag &= ~SPECIAL; - setint(vp, getpgrp()); - vp->flag |= SPECIAL; - break; } }