Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: $^O empty in windows powershell -- portableshell.bat ?

by Discipulus (Canon)
on Nov 22, 2022 at 07:59 UTC ( [id://11148299]=note: print w/replies, xml ) Need Help??


in reply to $^O empty in windows powershell

Hello WithABeard and welcome to the monastery and to the wonderful world of Perl!,

interesting finding, I tried it and.. more doubts coming out

PS C:\Users\me> Get-Host | Select-Object Version Version ------- 5.1.19041.1682 PS C:\Users\me> C:\EX_D\ulisseDUE\perl5.24.64bit\perl\bin\perl.exe -e +"print $^O;" PS C:\Users\me> + # no output as you noticed PS C:\Users\me> C:\EX_D\ulisseDUE\perl5.24.64bit\perl\bin\perl.exe -e +'print $^O;' MSWin32 + # ok with single quotes.. meh

But what happens if I cast portableshell.bat coming within my portable strawberry perl?

PS C:\Users\me> C:\EX_D\ulisseDUE\perl5.24.64bit\portableshell.bat ---------------------------------------------- Welcome to Strawberry Perl Portable Edition! * URL - http://www.strawberryperl.com/ * see README.TXT for more info ---------------------------------------------- Perl executable: C:\EX_D\ulisseDUE\perl5.24.64bit\perl\bin\perl.exe Perl version : 5.24.2 / MSWin32-x64-multi-thread C:\Users\me>perl -e "print $^O;" MSWin32 # + good 'ol expected behaviour C:\Users\me> C:\Users\me> C:\Users\me>perl -e 'print $^O;' Can't find string terminator "'" anywhere before EOF at -e line 1. # + no more single quote allowed

More: the powershell console is no more a powershell console! Get-Host gives me command not found

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: $^O empty in windows powershell -- portableshell.bat ?
by LanX (Saint) on Nov 22, 2022 at 09:20 UTC
    you have to distinguish between console/terminal-window and a shell running within°, and you can run multiple shells nested within each other.²

    in your case portableshell.bat starts a fresh cmd° shell as a sub-process inside the current terminal window, after typing exit you'll be back to the outer powershell.

    compare

    C:\tmp> C:\tmp>cmd # new sub shell Microsoft Windows [Version 10.0.19044.2251] (c) Microsoft Corporation. Alle Rechte vorbehalten. C:\tmp>exit # leave sub shell C:\tmp>

    vs

    C:\tmp>start cmd # new window with su +b shell C:\tmp>

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

    °) that's mostly *nix speak, not sure how they call these on win

    ²) the motivation for the name "shell" is a surrounding process managing an environment for sub-processes

Re^2: $^O empty in windows powershell -- portableshell.bat ?
by WithABeard (Sexton) on Nov 22, 2022 at 14:31 UTC

    Thanks! ^^

    Didn't know about the portableshell, it works fine :)
    I'll keep that handy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11148299]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-19 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found