From: Gurusamy Sarathy Date: Sat, 24 May 1997 07:50:36 +0000 (+1200) Subject: win32: user defined shell X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=174c211a66516a872d3a421681076bee9a56fa2b;p=p5sagit%2Fp5-mst-13.2.git win32: user defined shell This patch replaces the patch in win32.3 in the gnat collection. The reasons for reworking that patch should be evident from reading the patch below. p5p-msgid: 199705291339.JAA21682@aatma.engin.umich.edu --- diff --git a/pod/perlrun.pod b/pod/perlrun.pod index c4679e1..de7116d 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -567,6 +567,17 @@ The command used to load the debugger code. The default is: BEGIN { require 'perl5db.pl' } +=item PERL5SHELL (specific to WIN32 port) + +May be set to an alternative shell that perl must use internally for +executing "backtick" commands or system(). Perl doesn't use COMSPEC +for this purpose because COMSPEC has a high degree of variability +among users, leading to portability concerns. Besides, perl can use +a shell that may not be fit for interactive use, and setting COMSPEC +to such a shell may interfere with the proper functioning of other +programs (which usually look in COMSPEC to find a shell fit for +interactive use). + =item PERL_DEBUG_MSTATS Relevant only if your perl executable was built with B<-DDEBUGGING_MSTATS>, diff --git a/win32/win32.c b/win32/win32.c index 7fb0416..57e90a2 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -317,18 +317,19 @@ IdOS(void) static char * GetShell(void) { - static char* szWin95ShellEntry = "Win95Shell"; - static char* szWin95DefaultShell = "Cmd32.exe"; - static char* szWinNTDefaultShell = "cmd.exe"; - if (!ProbeEnv) { + char* defaultshell = (IsWinNT() ? "cmd.exe" : "command.com"); + /* we don't use COMSPEC here for two reasons: + * 1. the same reason perl on UNIX doesn't use SHELL--rampant and + * uncontrolled unportability of the ensuing scripts. + * 2. PERL5SHELL could be set to a shell that may not be fit for + * interactive use (which is what most programs look in COMSPEC + * for). + */ + char *usershell = getenv("PERL5SHELL"); + ProbeEnv = TRUE; - if (IsWin95()) { - strcpy(szShellPath, szWin95DefaultShell); - } - else { - strcpy(szShellPath, szWinNTDefaultShell); - } + strcpy(szShellPath, usershell ? usershell : defaultshell); } return szShellPath; }