--- src/cmd/ksh93/sh/main.c +++ src/cmd/ksh93/sh/main.c 2014-02-17 16:18:29.717590155 +0000 @@ -205,14 +205,38 @@ int sh_main(int ac, char *av[], Shinit_f { /* system profile */ sh_source(shp, iop, e_sysprofile); + } + /* make sure PWD is set up correctly */ + path_pwd(shp,1); +#if SHOPT_SYSRC + if(!sh_isoption(shp,SH_NOEXEC)) + { + if(!sh_isoption(shp,SH_NOUSRPROFILE) && !sh_isoption(shp,SH_PRIVILEGED) && sh_isoption(shp,SH_RC)) + { +#if SHOPT_BASH + if(sh_isoption(shp,SH_BASH) && !sh_isoption(shp,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(shp,SH_LOGIN_SHELL) && !sh_isoption(shp,SH_NOPROFILE)) + { if(!sh_isoption(shp,SH_NOUSRPROFILE) && !sh_isoption(shp,SH_PRIVILEGED)) { char **files = shp->gd->login_files; while ((name = *files++) && !sh_source(shp, iop, sh_mactry(shp,name))); } } - /* make sure PWD is set up correctly */ - path_pwd(shp,1); if(!sh_isoption(shp,SH_NOEXEC)) { if(!sh_isoption(shp,SH_NOUSRPROFILE) && !sh_isoption(shp,SH_PRIVILEGED) && sh_isoption(shp,SH_RC)) @@ -220,9 +243,6 @@ int sh_main(int ac, char *av[], Shinit_f #if SHOPT_BASH if(sh_isoption(shp,SH_BASH) && !sh_isoption(shp,SH_POSIX)) { -#if SHOPT_SYSRC - sh_source(shp, iop, e_bash_sysrc); -#endif sh_source(shp, iop, shp->gd->rcfile ? shp->gd->rcfile : sh_mactry(shp,(char*)e_bash_rc)); } else @@ -230,10 +250,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(!name || !strmatch(name, "?(.)/./*")) - sh_source(shp, iop, e_sysrc); -#endif if(name) { sh_source(shp, iop, name);