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

[Git Bash] Impossible to run a bash script from Windows Explorer if the path/name contains non-ASCII characters #2189

Closed
TestPolygon opened this issue May 12, 2019 · 14 comments
Milestone

Comments

@TestPolygon
Copy link

TestPolygon commented May 12, 2019

Description

I cannot properly run the .sh script by clicking on it if the path to the script contains non-ASCII character(s). The script does not work at all (I see only immediately closing of a console.).

I have Windows 10, 64-bit, Git-2.21.0 64-bit.

For example:
The content of the script:

#!/bin/bash
echo "Hello there!"
sleep 3

I can properly run the script in the console (git-bash.exe) in any way.

But, if I run the script from the Windows' Explorer by double-clicking on it:

  • If the path contains only ASCII characters: everything is OK.
  • If the path contains any non-ASCII character: the script (the console) closes immediately after the start, the script does not do any work.

Examples of the pathes:
Good:

  • C:\script.sh
  • C:\#Bash\New folder\script.sh
  • C:\#Bash\Pokmon.sh

"Bad":

  • C:\#Bash\Pokémon.sh Diacritic
  • C:\#Bash\Catálogo\script.sh ES
  • C:\#Bash\Новая папка\script.sh RU
  • C:\#Bash\New folder\脚本.sh ZN
  • C:\#Bash\Surrogate Pair 💧\script.sh Emoji

I would like to be able to run scripts by double-clicking if the path contains non-ASCII characters, at least characters from BMP (Basic Multilingual Plane).

@PhilipOakley
Copy link

Probably the place to start looking is the install scripts in the build-extra repo to see how the 'double clicking' is set up. I couldn't tell (personal ignorance ;-) if you are using the default windows mechanism for file associations etc to get the script to run, or if it was via a Git for Windows specific action mechanism (a right click option).

As a guess you are getting some character conversion issue between all the different apps/OSes/layers, such that you have, say, a windows characters being passed as if it is utf-8 or some such confusion.

@TestPolygon
Copy link
Author

TestPolygon commented May 13, 2019

Steps to reproduce

  1. You need Windows (I think any 10, 8, 7). Windows (NTFS) uses UTF-16 for file, directory naming.
  2. Create a bash script
  3. Install git (git-bash included) the latest or not version from the site (I use the default settings during installation)
  4. After installation, you can run the script from Windows Explorer
  5. If the path to the script (or the name of the bash script) contains non-ASCII characters it will not work.

@TestPolygon
Copy link
Author

TestPolygon commented May 13, 2019

I can run the script from the console in any case:
If the script is located in C:\#Bash\New Folder\💧\ and its name is water 💧.sh:
I can open git-bash.exe here using the context menu and run the script (even if the name of the script contains non-ASCII chars). It works.

User@User-PC MINGW64 /c/#Bash/New Folder/рџ’§                                                    
$ ./water\ ^Xрџ’§.sh
Hello there!

I see a little not presentable view of the output of the console, but the script works.
For name typing I use auto-complete (tab).

Another example:
Path: C:\#Bash\New Folder\Catálogo
Script: hello.sh
The console output:

User@User-PC MINGW64 /c/#Bash/New Folder/CatГЎlogo
$ ./hello.sh
Hello there!

@TestPolygon TestPolygon changed the title Cannot properly run (by double-clicking) the .sh script if the path contains non-ASCII characters [Git Bash] Cannot properly run (by double-clicking) the .sh script if the path contains non-ASCII characters May 13, 2019
@TestPolygon
Copy link
Author

TestPolygon commented May 15, 2019

The ability to run bash scripts from Windows' Explorer is very useful and convenient. In this case, a bash script behaves like a normal program(an .exe file). This is especially useful when you use the drag and drop mechanism to pass arguments to the script.

@TestPolygon TestPolygon changed the title [Git Bash] Cannot properly run (by double-clicking) the .sh script if the path contains non-ASCII characters [Git Bash] Impossible to run a bash script from Windows Explorer if the path/name contains non-ASCII characters May 15, 2019
@dscho dscho added this to the Next release milestone Nov 21, 2019
@dscho
Copy link
Member

dscho commented Nov 21, 2019

@TestPolygon sorry for the long wait. This should be fixed in the next version of Git for Windows. To make sure, please download the 64-bit package from https://dev.azure.com/johannes-schindelin/git/_build/results?buildId=4912&view=artifacts, unpack usr\bin\msys-2.0.dll into your C:\Program Files\Git (this should overwrite an existing file, you might want to back it up in case of unforeseen complications).

@TestPolygon
Copy link
Author

TestPolygon commented Nov 26, 2019

https://dev.azure.com/johannes-schindelin/git/_build/results?buildId=4912&view=artifacts

drive.google.com, dropbox.com, mega.nz or any other file sharing service?

@rimrul
Copy link
Member

rimrul commented Nov 26, 2019

@dscho that link requires a microsoft login. The download is probably only accessible to you.

@dscho
Copy link
Member

dscho commented Nov 26, 2019

that link requires a microsoft login

Well, boo.

https://dev.azure.com/johannes-schindelin/git/_build/results?buildId=4912&view=artifacts

drive.google.com, dropbox.com, mega.nz or any other file sharing service?

In the meantime, it made it into the Git for Windows SDK. Try this: https://github.com/git-for-windows/git-sdk-64/raw/master/usr/bin/msys-2.0.dll

@dscho
Copy link
Member

dscho commented Nov 26, 2019

There also has been a new snapshot in the meantime, if it is easier for you to run the Git for Windows installer.

@TestPolygon
Copy link
Author

TestPolygon commented Nov 26, 2019

There also has been a new snapshot

Running by double click works well now, but by drag and drop does not work well.

How to reproduce

  1. Use the bash script with the follow code:
#!/bin/bash

# Shows args count
args_count=$#
echo "Args count: $args_count"

# List of sorted args
printf "%s\n" "$(printf "%s\n" "$@" | sort -n)"

sleep 2
  1. Drag and drop any file on this .sh file.

If the bash script has "bad" character(s)* in its name or/and path, the script does not work at all when you drag and drop file(s) on it.

When only the files (that you drag and drop on the script) have "bad" character(s) in its name or/and path it seems to work.

*For example: éá脚本💧

@dscho
Copy link
Member

dscho commented Nov 26, 2019

I tried this with https://wingit.blob.core.windows.net/files/Git-prerelease-2.24.0.windows.2.14.g8715ee2266-64-bit.exe and it worked for me with the file name ähm.sh... but yes, I can reproduce with the "name" you provided.

Not sure when I will get to debug this, though.

@TestPolygon
Copy link
Author

TestPolygon commented Nov 27, 2019

it worked for me with the file name ähm.sh

It doesn't work on my machine.

I can reproduce with the "name" you provided.

It's an example set of "bad" chars. The existence of any (one) char of this set in the name or path of the script will break the work.

@rimrul
Copy link
Member

rimrul commented Nov 27, 2019

it worked for me with the file name ähm.sh

It doesn't work on my machine.

Probably locale dependent. While umlauts aren't ASCII, they are on a buch of DOS/Windows codepages.(850,858,859,865,1252,...)

dscho added a commit to git-for-windows/msys2-runtime that referenced this issue Dec 17, 2019
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Apr 27, 2020
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/msys2-runtime that referenced this issue Jun 4, 2020
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
git-for-windows-ci pushed a commit to git-for-windows/msys2-runtime that referenced this issue Jul 9, 2020
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/msys2-runtime that referenced this issue Aug 14, 2020
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/msys2-runtime that referenced this issue Aug 24, 2020
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Mar 30, 2021
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Apr 8, 2021
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Nov 11, 2021
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Dec 3, 2021
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Feb 1, 2022
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Member

dscho commented Mar 10, 2022

After being buried in my inbox for a long time, I stumbled over this again. At this stage I have to admit defeat: I won't be able to set aside enough time to investigate this issue properly.

I do not know whether this issue still reproduces with éá脚本💧.sh, but if it does, and if anybody here is willing to debug this (it's not really easy, but with a bit of tenacity it is totally doable), I can at least offer my assistance in the MSYS2 runtime with tons of inserted debug messages and then diagnosing the issue all the way to a fix.

dscho added a commit to dscho/msys2-runtime that referenced this issue May 3, 2022
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue May 6, 2022
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/msys2-runtime that referenced this issue May 8, 2022
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to git-for-windows/msys2-runtime that referenced this issue May 8, 2022
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue May 13, 2022
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Sep 5, 2022
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue May 12, 2023
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Jun 16, 2023
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Jun 19, 2023
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Sep 6, 2023
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Nov 29, 2023
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/Cygwin-msys2-fork that referenced this issue Dec 18, 2023
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189 and is
needed to let Git's t7400.108(submodule with UTF-8 name) pass, which
otherwise fails with:

  ++ git submodule add './å äö'
  fatal: repo URL: '"./å äö"' must be absolute or begin with ./|../

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Aug 30, 2024
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Sep 5, 2024
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/msys2-runtime that referenced this issue Sep 18, 2024
Internally, Cygwin already uses __utf8_mbtowc(), even if it still claims
to use the "ASCII" charset.

But the `MB_CUR_MAX` value (which is not actually a constant, but
dependent on the current locale) was still 1, which broke the initial
`globify()` call while parsing the the command-line in `build_argv()`
for non-ASCII arguments.

This fixes git-for-windows/git#2189

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants