* process ~/.mksrc only if FTALKING (i.e. interactive shell)

From: hondza <miscreant@tiscali.cz>
* document that in the manual page myself
* add regression test for that myself
This commit is contained in:
tg 2006-06-21 19:27:35 +00:00
parent 51d6772800
commit 569cf64ff1
3 changed files with 25 additions and 12 deletions

21
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.42 2006/05/27 11:36:50 tg Exp $ # $MirOS: src/bin/mksh/check.t,v 1.43 2006/06/21 19:27:35 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 $
@ -3738,13 +3738,26 @@ stdin:
expected-stdout: expected-stdout:
x x
--- ---
name: mkshrc-2 name: mkshrc-2a
description: description:
Check that ~/.mkshrc works correctly. Check that ~/.mkshrc works correctly.
Part 2: verify mkshrc can be read Part 2: verify mkshrc is not read (non-interactive shells)
file-setup: file 644 ".mkshrc" file-setup: file 644 ".mkshrc"
FNORD=42 FNORD=42
env-setup: !HOME=.!ENV=! env-setup: !HOME=.!ENV=!
stdin:
echo x $FNORD
expected-stdout:
x
---
name: mkshrc-2b
description:
Check that ~/.mkshrc works correctly.
Part 2: verify mkshrc can be read (interactive shells)
file-setup: file 644 ".mkshrc"
FNORD=42
arguments: !-i!
env-setup: !HOME=.!ENV=!PS1=!
stdin: stdin:
echo x $FNORD echo x $FNORD
expected-stdout: expected-stdout:
@ -3769,5 +3782,5 @@ category: pdksh
stdin: stdin:
echo $KSH_VERSION echo $KSH_VERSION
expected-stdout: expected-stdout:
@(#)MIRBSD KSH R27 2006/05/26 @(#)MIRBSD KSH R27 2006/06/21
--- ---

6
main.c
View File

@ -6,9 +6,9 @@
#define EXTERN /* define EXTERNs in sh.h */ #define EXTERN /* define EXTERNs in sh.h */
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.38 2006/05/26 23:36:19 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.39 2006/06/21 19:27:35 tg Exp $");
#define MKSH_VERSION "@(#)MIRBSD KSH R27 2006/05/26" #define MKSH_VERSION "@(#)MIRBSD KSH R27 2006/06/21"
extern char **environ; extern char **environ;
@ -294,7 +294,7 @@ main(int argc, char *argv[])
} }
if (Flag(FPRIVILEGED)) if (Flag(FPRIVILEGED))
include("/etc/suid_profile", 0, NULL, 1); include("/etc/suid_profile", 0, NULL, 1);
else { else if (Flag(FTALKING)) {
char *env_file; char *env_file;
/* include $ENV */ /* include $ENV */

10
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.35 2006/05/10 19:30:33 tg Exp $ .\" $MirOS: src/bin/mksh/mksh.1,v 1.36 2006/06/21 19:27:35 tg Exp $
.\" $OpenBSD: ksh.1,v 1.112 2006/04/22 14:10:36 jmc Exp $ .\" $OpenBSD: ksh.1,v 1.112 2006/04/22 14:10:36 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $ .\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
.\" .\"
@ -179,9 +179,9 @@ otherwise, the basename the shell was called with (i.e. argv[0]) is used.
.Pp .Pp
If the If the
.Ev ENV .Ev ENV
parameter is set when the shell starts (or, in the case of login shells, parameter is set when an interactive shell starts (or, in the case of login
after any profiles are processed), its value is subjected to parameter, shells, after any profiles are processed), its value is subjected to
command, arithmetic, and tilde parameter, command, arithmetic, and tilde
.Pq Sq ~ .Pq Sq ~
substitution and the resulting file substitution and the resulting file
(if any) is read and executed. (if any) is read and executed.
@ -5154,7 +5154,7 @@ deleted and a new prompt to be printed.
.Sh FILES .Sh FILES
.Bl -tag -width "/etc/suid_profileXX" -compact .Bl -tag -width "/etc/suid_profileXX" -compact
.It Pa ~/.mkshrc .It Pa ~/.mkshrc
User's startup script. User's startup script (interactive shells).
Used only if Used only if
.Ev ENV .Ev ENV
is unset or empty. is unset or empty.