This is the mail archive of the
mailing list for the Cygwin project.
Re: 1.7.1: unable to run the a bash script resides in chinese path using: c:\cygwin\bin\bash --login script.
>>Looks like there's some sort of GBK vs UTF-8 mixup going on, because
>>'éççéåå' is the same byte sequence in GBK as 'æææç' is in UTF-8:
> Could you please give me some hints on the tools
> used by you to obtain this conclusion?
That was just a hunch based on the length of the two strings, and I
confirmed it by pasting the strings into mintty running a utility for
echoing keycodes, switching charset as appropriate.
Anyway, I had a look into why the dosfilewarning prints the wrong
filename: it calls small_sprintf to print the message, and
small_sprintf uses the ANSI version of WriteFile to write to
STD_ERROR_HANDLE, so it ends up interpreting a UTF-8 string as GBK.
Seems sys_mbstowcs and WriteFileW are needed there.
>ÂThe actual directory name is 'æææç'.
>>Do you know what the encoding of your batch file is?
>> And have you got
>>any locale variables (LC_ALL, LC_CTYPE, LANG) set when invoking it?
> I'use the following settings in the same batch file:
> set LC_ALL=zh_CN.UTF-8
> set LC_CTYPE="zh_CN.UTF-8"
> set LANG=zh_CN.UTF-8
Thanks for the info. (Btw, setting all three locale variables is
overkill; just LC_ALL or LANG will do. Doesn't make a difference here
>>>>C:\cygwin\bin\bash --login "%~dp0myscript"
>>> I've found a more strange thing: If I change the batch file into the
>>> following form, then it will be run smoothly:
>>> @echo off
>>> C:\cygwin\bin\bash --login %~dp0myscript
>>> The QUOTATION MARK in the former is used to deal with the whitespaces
>>> appearing in the myscript's pathname, though this is relatively rare
>>> case. ?But in the latter case, if there're whitespaces in the
>>> myscript's pathname, the batch will fail to run.
>>Hmm, perhaps the argument mangling at program startup is using the
>>ANSI codepage (i.e. GBK in this case) when it should be using UTF-8?
> But, if I convert my batch file into UTF-8 (without BOM, CR/LF line
> endings) format, I'll meet the following error:
> "F:/zhaohs/Desktop/éççéåå/RestoreName4Elsevier.sh": No such
> Âfile or directory
That's easily explained: batch files are assumed (by Windows) to be
encoded in the OEM codepage, which on your system will be the same as
the ANSI codepage, i.e. GBK (aka CP936). So if your batch file
actually contains UTF-8, you get mojibake.
I'm stumped though as to why your example works without quotation when
it does without them, especially considering that bash actually
reports the correct filename.
> /usr/bin/bash: "F:\zhaohs\Desktop\æææç\myscript": No such file or
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple