Support Windows via pwsh - Powershell needs to be installed manually#77
Support Windows via pwsh - Powershell needs to be installed manually#77azriel91 wants to merge 6 commits into
pwsh - Powershell needs to be installed manually#77Conversation
|
Thanks for the PR. I'll try to give it a review tomorrow 👀 |
|
|
||
| #[cfg(target_os = "windows")] | ||
| { | ||
| Ok(out) |
There was a problem hiding this comment.
This can contain carriage returns (\r) according to the tests, so it should replace them like in line 121.
There was a problem hiding this comment.
ah, wasn't sure if we wanted \rs in Windows land.
Shall remove them.
| if !cmp_paths(std::env::current_dir()?, cwd) { | ||
| std::env::set_current_dir(cwd)?; | ||
| if !cmp_paths(std::env::current_dir()?, &cwd_before) { | ||
| std::env::set_current_dir(cwd_before)?; |
There was a problem hiding this comment.
That's not what the original code did. When you do
to-html "cd .." "ls"The 1st command changes directory, and the 2nd command should print the entries in that directory. The problem was that running cd in fake_tty::command does not affect the working directory of the current process, so I wrote this "hack".
There was a problem hiding this comment.
Expressed this behavior in a test with this commit (f65923c). It indeed succeeds on main, but fails with this PR
(force pushed to fix mac and linux using slightly different formatting for ls output)
There was a problem hiding this comment.
Whelp that's odd. That change appears to fail consistently on only the ubuntu, rustc beta job with output that looks identical to not actually changing the current working directory. I'm not able to reproduce it locally when running the 1.88.0-beta.3 toolchain on Arch :/
https://github.com/CosmicHorrorDev/to-html/actions/runs/15090969623/job/42419546987
There was a problem hiding this comment.
ah, looks like I've never changed directories when using to-html!
I've fixed the directory changing code -- getting it to work on Windows is a little hacky (std::env::set_current_dir doesn't like pwd outputs, which are different depending on which bash you're running).
@CosmicHorrorDev I've taken that commit and added it to this branch (and used ls -1 to avoid the \t issue).
|
Also, I believe this will means that What I'd expect is that |
|
Thank you for working on this! I'll have to test it more thoroughly. |
29e6eb5 to
a5ced54
Compare
|
I'll leave the review up to @Aloso since it seems like he's up for it 🎉 One thing that I would like is if we could add windows in our |
|
Heya @Aloso, would you mind if I added an The (I haven't checked if there's a way to get the origin location by looking for the error's backtrace) |
|
@azriel91 you can do that. But what I think would help more is to add |
|

If we use the
Powershellbinary, it defaults to Powershell 1.0, which doesn't have ANSI support; I think it only got introduced in Powershell 5.0.After installing powershell manually,
pwshis available on thePATH.I know some windows users will have git-bash installed, but I don't, so as a first cut I just added support for
pwsh.I added tests for windows; and I changed the current working directory restoration to not use
pwd, so it would be good to test on a non-windows system with a command that changes the working dir.Screenshot:
to-html 'cargo build --color=always'