Subject: | Add support for Windows PowerShell |
local::lib assumes that it's running under the legacy cmd.exe rather than PowerShell when used on Windows systems. Given that PowerShell is the recommended command line environment for Windows users, local::lib should assume that it's running on PowerShell when $^O eq 'MSWin32' unless it can detect otherwise.
perl -Mlocal::lib should provide output that looks similar the following when executed from within PowerShell.
$env:PERL_LOCAL_LIB_ROOT = "$env:PERL_LOCAL_LIB_ROOT;C:\Users\joeaverage\perl5"
$env:PERL_MB_OPT = "--install_base C:\Users\joeaverage\perl5"
$env:PERL_MM_OPT = "INSTALL_BASE=C:\Users\joeaverage\perl5"
$env:PERL5LIB = "C:\Users\joeaverage\perl5\lib\perl5;$env:PERL5LIB"
$env:PATH = "C:\Users\joeaverage\perl5\bin;$env:PATH"
Environment variables for PowerShell differ from cmd.exe in the following ways.
1. Environment variables are prefixed with '$env:'
2. Optional spaces can appear on either side of the assignment operator. I've added them in the example above for readability's sake.
3. The value to be assigned must be quoted since it will contain semicolons which is a command separator
The Win32 API could be used to check the parent process. Shell::Guess implements a small subroutine that uses Win32::Process::Info to get the parent process name. Maybe that code can be harvested to do the minimal checking needed for local::lib to see if it's being called from cmd.exe.
In the documentation it should be mentioned that the user can execute the following to make the variables are set by their shell startup script (provided they have one).
echo 'perl -Mlocal::lib | % { iex $_ }' >>$PROFILE
I'd be happy to help out with any questions on how to fix this bug. I'm not sure I know enough to make the fix myself without mentoring. Email me if that's something you'd prefer to do.