-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Username with one or more spaces causes an error #849
Comments
Using $HOME directly in the command isn't something you can do when creating a file in a program, you have to expand the path. But an appropriate escaping is probably missing. |
This also happens when trying to use inshellisense, by the way. PS …\User Name\Development> inshellisense
'C:\Users\User' is not recognized as an internal or external command,
operable program or batch file. |
It seems there are two errors that should be resolved.
PS …\Development\broot> br
File not found: "C:\\Users\\User Name\\AppData\\Local\\Temp\\tmpBA8F.tmp" broot/src/shell_install/powershell.rs Lines 27 to 33 in 8f50c72
In line 29 of powershell.rs, Plus, I noticed that |
Here's a hacky solution I've discovered (with help of GPT)
# https://github.com/Canop/broot/issues/460#issuecomment-1303005689
Function br {
$args = $args -join ' '
$cmd_file = New-TemporaryFile
$cmd_file_path = $cmd_file.FullName
$quoted_cmd_file = "`"$cmd_file_path`""
$process = Start-Process -FilePath 'broot.exe' `
-ArgumentList "--outcmd $quoted_cmd_file $args" `
-NoNewWindow -PassThru -WorkingDirectory $PWD
Wait-Process -InputObject $process #Faster than Start-Process -Wait
If ($process.ExitCode -eq 0) {
$cmd = Get-Content $cmd_file_path
Remove-Item -Path $cmd_file_path
If ($cmd -ne $null) { Invoke-Expression -Command $cmd }
} Else {
Remove-Item -Path $cmd_file_path
Write-Host "`n" # Newline to tidy up broot unexpected termination
Write-Error "broot.exe exited with error code $($process.ExitCode)"
}
} I know the code is pretty dirty and hacky but it now works fine. Just a workaround for people who are still struggling with this problem. |
Instead of manually replacing those files, can a clean enough script be proposed in a PR ? |
I'm working on it but since I'm not a very good programmer, it may take some time. |
Nobody's born a very good programmer. Make your PR and we'll try to have some people with powershell knowledge review it and provide advice or fixes. |
Steps to reproduce
br --install
broot --install
(when username is "User Name")
. C:\Users\User\ Name\AppData\Roaming\dystroy\broot\config\launcher\powershell\br.ps1
Possible solution
Use $HOME environment variable instead so windows will automatically expand it on execution appropriately.
The text was updated successfully, but these errors were encountered: