Web lists-archives.com

Re: cmd.exe and file name conversion from comman line argument




On 2018-07-26 18:56, h_ono@xxxxxxxxxxxxxxxx wrote:
> There is strange behavior when naming a file from command line argument in 
> cmd.exe console, using touch or mv.
> I use:
> touch (GNU coreutils) 8.26
> Packaged by Cygwin (8.26-2)
> cygwin1.dll version 2.10.0
> in cmd.exe, doing
>> touch aaa
> and
>> touch 'aaa'
> give same file name aaa.
>> ls
>  aaa
> but, when I use Japanese characters as file name, it gives different file 
> names with and without the quote.
>> env LANG=ja_JP.UTF-8 touch あああ
> gives
>> env LANG=ja_JP.UTF-8 ls
>   あああ
> but,
>> env LANG=ja_JP.UTF-8 touch 'あああ'
> gives file name with quote not stripped.
>> env LANG=ja_JP.UTF-8 ls
>   'あああ'
> If called from mintty + bash,
> $ env LANG=ja_JP.UTF-8 touch 'あああ'
> gives
> $ env LANG=ja_JP.UTF-8 ls
>   あああ
> The problem is when I create a file containing spaces in its name.
> Creating a file in cmd.exe like:
>> env LANG=ja_JP.UTF-8 touch 'ああ あ'
> gives
>> env LANG=ja_JP.UTF-8 ls
> "'ああ あ'"
> (which is a file named 'ああ あ', not ああ あ)
> It seems, there is no way to create a file containing a space in its name, 
> like
>  ああ あ
> with commands such as touch or mv.
> Is it a normal behavior, or a bug?
> Is there any way to create a file containing Japanese characters and spaces
> in its name without quote added?
> FYI, With old cygwin (cygwin1.dll version 1.5.25), there were not such 
> problem. Even from cmd.exe,
>> touch 'ああ あ'
> gave a file named 'ああ あ' (without the quote in real.)

Under a Unix shell, both double quote " and single quote/apostrophe ' are
quoting metacharacters, as is backquote/grave `, but any character may be used
in a file name by prefixing with the escape character \.
Under Windows cmd only double quote " is a quoting metacharacter; path spec
delimiters : \ /, wild card characters * ?, and redirection characters | < > are
also not allowed in file names. So to create a Windows file name with a space
from cmd, use only double quotes " around the name.
Under Cygwin, any file name characters disallowed by Windows are mapped into
Unicode private use area characters, but converted back on display, so under
Windows programs those files' long names will display characters without
assigned glyphs.

Note that in ls, nongraphic characters in a file name entry e.g. space, causes
that file name entry to be displayed single quoted 'a b'; specifying ls
-N|--literal|--quoting-style=literal omits the single quotes, but nongraphic
characters are displayed on terminals as question marks ?, unless
--show-control-chars is also specified.
Run "info ls 'Formatting the file names'" to see full explanations.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple