Skip to content
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

WSL2 on Windows 11 -bash: warning: command substitution: ignored null byte in input #1083

Closed
1 task done
iSnackyCracky opened this issue Oct 19, 2021 · 6 comments · Fixed by #1084
Closed
1 task done
Assignees
Labels
🐛 bug Something isn't working

Comments

@iSnackyCracky
Copy link

Code of Conduct

  • I agree to follow this project's Code of Conduct

What happened?

I've just installed oh-my-posh on Windows 11 using winget (have been using quite an old version before, but only on windows).

It works just fine for posh and pwsh but now I tried using it in WSL (Ubuntu) with bash (using the oh-my-posh-wsl binary that is provided via the winget install)

When I follow the documentation and just execute

eval "$(oh-my-posh-wsl --init --shell bash --config /mnt/c/Users/snacky/omp/snacky.omp.json)"

(the config file is the same I'm using for pwsh on Windows)

the prompt changes (and looks just as good as expected) but on prompt (no matter if running a command or just hitting enter on an empty line) I get a

-bash: warning: command substitution: ignored null byte in input

Version

oh-my-posh-wsl -version
5.8.0

Theme

custom theme (based on the default "jandedobbeleer.omp.json")

What OS are you seeing the problem on?

Windows, Linux

Which shell are you using?

bash

Relevant log output

No response

@iSnackyCracky iSnackyCracky added the 🐛 bug Something isn't working label Oct 19, 2021
@JanDeDobbeleer
Copy link
Owner

@iSnackyCracky I'll try to reproduce this. What version of bash are you using?

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Oct 19, 2021

Found this interesting post. Will see if that works and push that change.

EDIT: found an additional issue, timing indication doesn't work anymore somehow. Might need some more time.

@iSnackyCracky
Copy link
Author

Wow, that was probably the fastest response I've ever gotten to an Issue <3

Bash version used is GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)

@iSnackyCracky
Copy link
Author

Found this interesting post. Will see if that works and push that change.

Yeah, I had seen this too, but didn't really understand how and where to implement it at first.
I've now looked into it again and also at the raw output of oh-my-posh-wsl --init --shell bash --config <config>

I've modified the PS1= line inside the _omp_hook():

from
PS1="$(/mnt/c/Users/snacky/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl --config="$POSH_THEME" --shell=bash --error="$ret" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count")"

to
PS1="$(/mnt/c/Users/snacky/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl --config="$POSH_THEME" --shell=bash --error="$ret" --execution-time="$omp_elapsed" --stack-count="$omp_stack_count" | tr -d '\0')"

and ran that code manually - seems to work just fine then (at least no more warnings)

@JanDeDobbeleer
Copy link
Owner

Cool, I was on the wrong path it seems. I'll push a fix!

Copy link

github-actions bot commented Apr 1, 2024

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues.
If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants