-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Don't fail when powershell.exe is missing #67
Don't fail when powershell.exe is missing #67
Conversation
On some platforms, `uname -a` contains `Microsoft` but `powershell.exe` is not in `$PATH`, so `if powershell.exe ... 2>/dev/null` still displays an error: ``` if powershell.exe -command "Import-Module -Name BurntToast" 2>/dev/null; echo true; end powershell.exe: command not found fish: if powershell.exe -command "Import-Module -Name BurntToast" 2>/dev/null; echo true; end ^ ``` Add a check to `command -v powershell.exe` to avoid the error message.
Here's the error that I get e.g. after running
|
@9999years what platform are you running this in? Would the default bell sound work in your case?
|
The bell sound works! This happens on WSL 1 on my laptop, but not on my desktop (strange, because they're theoretically identical systems). We could also get the PowerShell path on WSL with something like:
and then:
|
Sounds like we should do both. Improve the chances of getting the powershell binary, and not fail if we don't. @9999years would you mind making these changes? Thanks! |
- On WSL, `uname -a` contains `Microsoft` but `powershell.exe` is often not in `$PATH`; therefore, we use `wslpath` and `wslvar` to make a better guess as to `powershell.exe`'s location if we can't find it in `$PATH`. - Fall back to the bell sound (`echo -e "\a"`) if we can't find PowerShell or PowerShell can't import the `BurntToast` module.
Made the changes and made sure the logic works on WSL with |
Looks good, thanks! |
On some platforms,
uname -a
containsMicrosoft
butpowershell.exe
is not in$PATH
, soif powershell.exe ... 2>/dev/null
still displays an error:Add a check to
command -v powershell.exe
to avoid the error message.