ksh/ksh93-profile.dif

67 lines
1.9 KiB
Plaintext

--- src/cmd/ksh93/sh/main.c
+++ src/cmd/ksh93/sh/main.c 2008-09-11 17:10:58.130673081 +0200
@@ -210,17 +210,39 @@ int sh_main(int ac, char *av[], Shinit_f
}
job_init(shp,sh_isoption(SH_LOGIN_SHELL));
if(sh_isoption(SH_LOGIN_SHELL))
- {
/* system profile */
sh_source(shp, iop, e_sysprofile);
+ /* make sure PWD is set up correctly */
+ path_pwd(1);
+#if SHOPT_SYSRC
+ if(!sh_isoption(SH_NOEXEC))
+ {
+ if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED) && sh_isoption(SH_RC))
+ {
+#if SHOPT_BASH
+ if(sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX))
+ sh_source(shp, iop, e_bash_sysrc);
+ else
+#endif
+ {
+ if(name = sh_mactry(shp,nv_getval(ENVNOD)))
+ name = *name ? strdup(name) : (char*)0;
+ if(!name || !strmatch(name, "?(.)/./*"))
+ sh_source(shp, iop, e_sysrc);
+ if(name)
+ free(name);
+ }
+ }
+ }
+#endif
+ if(sh_isoption(SH_LOGIN_SHELL) && !sh_isoption(SH_NOPROFILE))
+ {
if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED))
{
char **files = shp->login_files;
while ((name = *files++) && !sh_source(shp, iop, sh_mactry(shp,name)));
}
}
- /* make sure PWD is set up correctly */
- path_pwd(1);
if(!sh_isoption(SH_NOEXEC))
{
if(!sh_isoption(SH_NOUSRPROFILE) && !sh_isoption(SH_PRIVILEGED) && sh_isoption(SH_RC))
@@ -228,9 +250,6 @@ int sh_main(int ac, char *av[], Shinit_f
#if SHOPT_BASH
if(sh_isoption(SH_BASH) && !sh_isoption(SH_POSIX))
{
-#if SHOPT_SYSRC
- sh_source(shp, iop, e_bash_sysrc);
-#endif
sh_source(shp, iop, shp->rcfile ? shp->rcfile : sh_mactry(shp,(char*)e_bash_rc));
}
else
@@ -238,10 +257,6 @@ int sh_main(int ac, char *av[], Shinit_f
{
if(name = sh_mactry(shp,nv_getval(ENVNOD)))
name = *name ? strdup(name) : (char*)0;
-#if SHOPT_SYSRC
- if(!strmatch(name, "?(.)/./*"))
- sh_source(shp, iop, e_sysrc);
-#endif
if(name)
{
sh_source(shp, iop, name);