Comments (4)
Here are some things that are true in a Remoting session:
- Console.IsInputRedirected
- Console.IsOutputRedirected
- The PowerShell global session variable
$PSSenderInfo
is not null and is a dictionary- This one likely isn't accessible without referencing the PowerShell APIs because they're not environment variables - they're just ambient data in the PowerShell application itself, and aren't directly exposed to anything inside it as far as I know.
But...
The redirection alone is probably enough, at least with how Terminal.Gui currently works. Redirection of the in and out streams will break it, so a simple check against those first two boolean properties before doing anything else and throwing a meaningful exception or something is probably sufficient.
Any thoughts?
from terminal.gui.
And just for the record, I don't think TG breaking on redirection is a good thing to be a permanent limitation. But I suspect it's a bit too much for V2 to make it work with that, so that seems like an acceptable means of detecting an unsupported environment and terminating, right now.
from terminal.gui.
I played around with some code for a bit since I got annoyingly fixated on this (done now though)...
The environment variables that are set make it almost look like a normal interactive session, aside from missing $TERM, $COLUMNS, and $LINES. Those are simply not even defined, by default, at least in a PS Remoting session from my Windows 11 PC with PS 7.5 preview 3 remoting to an Ubuntu 24.04 system with the same version of PowerShell. It even shows as being on top of bash, in this particular environment, which was a semi-surprising thing since I figured the login shell for the user would have been bypassed. But it appears the user's default shell is being loaded. I changed the default shell for a user to sh and opened a new session to check that hypothesis, which was confirmed.
I don't know why the behavior when you've entered the session isn't to re-redirect the stdin and stdout streams to the active shell, but it isn't, so PS Remoting is currently just not compatible with a TG application.
There are a few other environment variables that are not there, so it's clearly not loading the shell with the logged in user's profile (I've got a .bashrc that sets a bunch of stuff up and it wasn't there in the bash case), but they're not helpful or in any significant way an actual indicator of what the environment is, anyway, as far as I can see without spending more time on it that I don't want to waste.
I suppose another option for validating the environment - which would need to be conditionally skipped if AoT compiled, because it isn't trim friendly - would be to attempt to load the System.Management.Automation library into the AppDomain to make the check, so that it could be used without having a hard compile-time dependency. Inability to load the assembly would mean you're not in PowerShell (probably), and if you can load it you can access the PS session variables through that API... But that's gross IMO, and the checks for redirection seem good enough for the time being.
Besides, it's likely to be a corner case anyway. Even if usage does explode after V2 release and people start running into the problem, it can simply be addressed by documenting it as an unsupported environment until or unless a driver that works with it is ever created by some ambitious individual. 🤷♂️
And if you have the ability to use PSRemoting over SSH, you already apparently have SSH, so you can just connect in a normal session and move on with life.
from terminal.gui.
Huh. Maybe it's lying actually...
Process list shows the pwsh-preview process directly owned by sshd, so... 🤷♂️
Back to work on important stuff now...
from terminal.gui.
Related Issues (20)
- Automate getting cultures from the embedded resources strings for self-contained app.
- Focus gets confused with `ContextMenu`. HOT 1
- Overlapped broken on the v2_develop branch using the BackgroundWorkerCollection scenario. HOT 7
- Checked renamed State in CheckBox HOT 10
- Some uses of the `CheckStyle` enum are buggy
- `ShadowStyle.Transparent` is not rendering bottom-left corner correctly
- TGD: Master Issue tracking TG issues that must be fixed in v2 HOT 21
- Ensure `OCGV` is working
- Setting `Menus` causes unexpected Exception HOT 13
- Ctrl-Q Closes Application HOT 8
- v2: Keyboard navigation on MessageBox no longer working HOT 3
- V2 crashes under Git For Windows bash session
- AppendAutocomplete not rendering correctly (v2)
- Shortcut crashes when removed from SuperView and ColorScheme set to null HOT 1
- Running Application.Begin sometimes crashes on keybindings HOT 11
- Null reference in v2 in FindDeepestView HOT 4
- Proposal: Focus/Navigation Changes - e.g. Remove `Tabindex` and `TabIndexes` in v2 HOT 8
- Using emoji HOT 3
- Mac Error - Error opening terminal: unknown. HOT 4
- NativeAot project isn't using the correct release nuget package.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terminal.gui.