New feature: read ~/.mkshrc during startup, after the profiles
have been read, for non-priviledgued shells only. If $ENV is set, ~/.mkshrc is ignored (even if the file pointed to by $ENV does not exist in the first place). Feature requested by Jari Aalto for portable mksh because some operating systems' vendors do not allow touching the profile. Initial diff and manual page addition by Jari Aalto <jari.aalto@cante.net> Code changes and manual page correctness by me.
This commit is contained in:
parent
41f310751e
commit
c4ef5b801a
4
check.t
4
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.37 2006/01/29 20:56:54 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.38 2006/05/08 11:42:36 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 $
|
||||
@ -3736,5 +3736,5 @@ category: pdksh
|
||||
stdin:
|
||||
echo $KSH_VERSION
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R26 2006/01/29
|
||||
@(#)MIRBSD KSH R26 2006/05/08
|
||||
---
|
||||
|
7
main.c
7
main.c
@ -6,9 +6,9 @@
|
||||
#define EXTERN /* define EXTERNs in sh.h */
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.34 2006/01/30 12:37:23 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.35 2006/05/08 11:42:36 tg Exp $");
|
||||
|
||||
#define MKSH_VERSION "@(#)MIRBSD KSH R26 2006/01/29"
|
||||
#define MKSH_VERSION "@(#)MIRBSD KSH R26 2006/05/08"
|
||||
|
||||
extern char **environ;
|
||||
|
||||
@ -298,7 +298,8 @@ main(int argc, char *argv[])
|
||||
char *env_file;
|
||||
|
||||
/* include $ENV */
|
||||
env_file = substitute(str_val(global("ENV")), DOTILDE);
|
||||
env_file = substitute(substitute("${ENV:-~/.mkshrc}", 0),
|
||||
DOTILDE);
|
||||
if (*env_file != '\0')
|
||||
include(env_file, 0, NULL, 1);
|
||||
}
|
||||
|
21
mksh.1
21
mksh.1
@ -1,4 +1,4 @@
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.30 2006/02/16 11:48:32 tg Exp $
|
||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.31 2006/05/08 11:42:36 tg Exp $
|
||||
.\" $OpenBSD: ksh.1,v 1.109 2005/12/06 20:40:02 jmc Exp $
|
||||
.\" $OpenBSD: sh.1tbl,v 1.53 2004/12/10 01:56:56 jaredy Exp $
|
||||
.\"
|
||||
@ -95,7 +95,9 @@ A privileged shell does not process
|
||||
.Pa $HOME/.profile
|
||||
nor the
|
||||
.Ev ENV
|
||||
parameter (see below).
|
||||
parameter or
|
||||
.Pa $HOME/.mkshrc
|
||||
(see below).
|
||||
Instead, the file
|
||||
.Pa /etc/suid_profile
|
||||
is processed.
|
||||
@ -183,6 +185,16 @@ command, arithmetic, and tilde
|
||||
.Pq Sq ~
|
||||
substitution and the resulting file
|
||||
(if any) is read and executed.
|
||||
If the
|
||||
.Ev ENV
|
||||
variable is unset, the file
|
||||
.Pa $HOME/.mkshrc
|
||||
is read and processed like above instead, leaving
|
||||
.Ev ENV
|
||||
unset in the shell environment.
|
||||
This processing does not occur if
|
||||
.Ev ENV
|
||||
is set to a non-existing filename.
|
||||
.Pp
|
||||
The exit status of the shell is 127 if the command file specified on the
|
||||
command line could not be opened, or non-zero if a fatal syntax error
|
||||
@ -5121,6 +5133,11 @@ deleted and a new prompt to be printed.
|
||||
.El
|
||||
.Sh FILES
|
||||
.Bl -tag -width "/etc/suid_profileXX" -compact
|
||||
.It Pa ~/.mkshrc
|
||||
User's startup script.
|
||||
Used only if
|
||||
.Ev ENV
|
||||
is unset.
|
||||
.It Pa ~/.profile
|
||||
User's login profile.
|
||||
.It Pa /etc/profile
|
||||
|
Loading…
Reference in New Issue
Block a user