-
Notifications
You must be signed in to change notification settings - Fork 319
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
UTF-8 character in the default shell profile causes rendering issues without a $LANG or locale configured #664
Comments
Thanks for reporting! I believe all of the non-printable characters are already wrapped with escaped square brackets in https://github.com/devcontainers/features/blob/main/src/common-utils/scripts/bash_theme_snippet.sh as well as the zsh variant, but the theme prompt is quite large so it's possible there's a missing character somewhere in there. We'll need to take a closer look to double check. |
All the actual non-printable characters are wrapped, but the arrow is causing issues and removing or wrapping it fixes those issues. It's not non-printable, which is why I don't know if wrapping it as if it was is a reasonable idea or not :) |
Thanks for clarifying! I'm not sure whether that would cause any problems either, but it seems like it would since bash will still have an incorrect understanding of the actual printable width of the line. I'm not able to reproduce the problem you describe. Here's a recording of my test in zsh. Screen.Recording.2023-08-18.at.5.34.26.PM.movCould you capture a video of the issue in VS Code with
|
Attached a screencap. I'm on Debian sid, I'm using Also noticed you don't actually have to be at the bottom of the tty to see this while recording the screencap below. An example of what I can repro it with is https://github.com/NVIDIA/cccl/blob/main/.devcontainer/cuda12.2-gcc12/devcontainer.json. screencap.mp4 |
I'm able to reproduce using |
devcontainer exec
overwrites characters in the terminal when there are wrapped output lines
@chrmarti can you take a look at this? |
I can also reproduce with |
I checked all of the escapes in https://github.com/devcontainers/features/blob/main/src/common-utils/scripts/bash_theme_snippet.sh is they look correct to me. All of the non-printable sequences are wrapped in square brackets. I was not able to reproduce in pure |
Here's a more minimal repro: docker run --rm -it mcr.microsoft.com/devcontainers/base:ubuntu
echo ➜ Then hit the up and down arrow back and forth and notice one character is overwritten at a time. Screen.Recording.2023-08-22.at.10.21.01.AM.movIf you clear out the profile and set it to a minimal profile config before doing the echo, the same thing happens: docker run --rm -it mcr.microsoft.com/devcontainers/base:ubuntu
export PS1="\s-\v\$"
echo ➜ Screen.Recording.2023-08-22.at.10.23.39.AM.movSimilarly, spawning the initial bash shell with
The UTF-8 character in the output seems to be messing up width calculation somehow. If you try with the
I did notice that changing the locale configured in
I don't know enough about how locales are configured to explain this difference, and it's still not clear to me why this only reproduces in |
devcontainer exec
overwrites characters in the terminal when there are wrapped output linesdevcontainer exec
overwrites characters in the terminal when there are UTF-8 characters in the output
The line length is definitely wrong in the base devcontainers image when no locale is explicitly set.
Compared to
Knowing that it's a locale issue also helps explain why it works in VS Code interactive terminals and SSH shells. In VS Code and SSH, At this point, it's definitely not a CLI bug. It's either in the image or the common-utils feature, although it's tied to the locales rather than the PS1 escaping. Transferring back to the features repo for now. |
devcontainer exec
overwrites characters in the terminal when there are UTF-8 characters in the output
Walking up the stack a bit on the image where it's broken, the upstream image
|
Looking at the Dockerfile for |
same. does LANG not stay exported after common-utils install? features/src/common-utils/main.sh Lines 144 to 149 in 084df81
on debian
|
I've tried this with both bash and zsh. They are both broken, but in slightly different ways; I think the breakage in bash is worse, but they both are not pretty.
Steps to reproduce and demonstrate what I mean:
I believe that this is related to this problem, though the linked original talks specifically about non-printable characters, and the arrow is definitely printable. Nevertheless, with it being a multi-byte character, it appears to me that using the solution normally used for the non-printable characters, i.e. wrapping it with
\[\]
in PS1, fixes the issue for bash. I am unsure if this is a viable solution to this problem, which is why I'm filing this as an issue and not with a specific patch. I assume that the zsh method of escaping the characters in PROMPT would similarly work, but I have not verified this.The text was updated successfully, but these errors were encountered: