Skip to content

Built-in echo behavior varies with different unicode notations of same character #1986

Closed
@am11

Description

@am11
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
    v2.16.1(2)
$ git --version --build-options

git version 2.16.1.windows.2
cpu: x86_64
built from commit: e78e3c8ee9c219723d60aa1bccd8348c2269b9ba
sizeof-long: 4
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
:: get OS version
C:\> ver

Microsoft Windows [Version 10.0.18298.1000]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
$ cat /etc/install-options.txt
Editor Option: Nano
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Disabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

I am using latest insider build of Windows 10 (last updatd 15.12.2018).

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Bash

  • What commands did you run to trigger this issue?
echo -e "\U2744"
echo -e "\U00002744"
echo -e "\xE2\x9D\x84\xEF\xB8\x8F"
echo -e "\0342\0235\0204\0357\0270\0217"

/bin/echo -e "\xE2\x9D\x84\xEF\xB8\x8F"
/bin/echo -e "\0342\0235\0204\0357\0270\0217"

Exception note: since /bin/echo and built-in (GNU) echo are different, /bin/echo.exe doesn't understand \U notations and echoes them literally even with escape interpretation -e (e.g. try /bin/echo -e "\U2744" then echo -e "\U2744").

  • What did you expect to occur after running these commands?

All of the commands to print full-width Unicode 1.1 Snowflake character (U+2744): ❄️

  • What actually happened instead?

Only \U notations display the full character, \x and \0 are displayed partially:

image

It seems like the built-in echo falls back on the behavior of /bin/echo.exe in case of hex \x and octal \0 notations.

Moreover, in ~/.bash_profile, I am using \U notation (which in my understanding /bin/echo.exe doesn't interpret at all), yet:

export PS1=$'\e[1;94m\\t\e[0m:\e[1;36m\U2744\e[0m \w \$ '

# note the use of \U2744, the rest of markers are colors and special notations:
# http://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html

results in rendering of partial snowflake:

image

Seems like there is a third printer implementation, that does interpret \U notation but does not adjust the width of character like built-in echo -e '\U2744'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions