* cmd.exe and file name conversion from comman line argument @ 2018-07-27 5:24 h_ono 2018-07-27 6:56 ` Marco Atzeri ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: h_ono @ 2018-07-27 5:24 UTC (permalink / raw) To: cygwin Hello, There is strange behavior when naming a file from command line argument in cmd.exe cosole, 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.) ---------- Hiroo Ono -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: cmd.exe and file name conversion from comman line argument 2018-07-27 5:24 cmd.exe and file name conversion from comman line argument h_ono @ 2018-07-27 6:56 ` Marco Atzeri 2018-07-27 7:27 ` Andrey Repin 2018-07-27 8:08 ` Brian Inglis 2 siblings, 0 replies; 8+ messages in thread From: Marco Atzeri @ 2018-07-27 6:56 UTC (permalink / raw) To: cygwin Am 27.07.2018 um 02:56 schrieb h_ono@ot.olympus.co.jp: > Hello, > > There is strange behavior when naming a file from command line argument in > cmd.exe cosole, > 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 what happen if you use bash ? Regards Marco --- Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: cmd.exe and file name conversion from comman line argument 2018-07-27 5:24 cmd.exe and file name conversion from comman line argument h_ono 2018-07-27 6:56 ` Marco Atzeri @ 2018-07-27 7:27 ` Andrey Repin 2018-07-27 8:08 ` Brian Inglis 2 siblings, 0 replies; 8+ messages in thread From: Andrey Repin @ 2018-07-27 7:27 UTC (permalink / raw) To: h_ono, cygwin [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset=utf-8, Size: 2399 bytes --] Greetings, h_ono@ot.olympus.co.jp! > Hello, > There is strange behavior when naming a file from command line argument in > cmd.exe cosole, > using touch or mv. No, your comparison is not fair. > I use: > touch (GNU coreutils) 8.26 > Packaged by Cygwin (8.26-2) You're using "env" to begin with, which alters processing of parameters. But I can't reproduce your case. The result is definitely does not contain the quotes. chcp 65001 set LANG=ru_RU.UTF-8 env LANG=ja_JP.UTF-8 touch 'ããã' It creates exactly the name I'd expect, even though I can't see it in console. But Explorer don't lie and shows it proper. > 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.) -- With best regards, Andrey Repin Friday, July 27, 2018 7:50:49 Sorry for my terrible english...\x03BKCB\x1cØ\x19[H\x1c\^[Ü\x1cÎ\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÜ\x1cØ\x19[\Ë\x1d^[[\x03BTN\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÙ\KÃB^[ØÝ[Y[\x18]\x1a[Û\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÙ^[ØÜË\x1d^[[\x03B[ÝXØÜXH\x1a[Î\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÛ[\vÈÝ[ÝXØÜXK\Ú[\^[\x19CBB ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: cmd.exe and file name conversion from comman line argument 2018-07-27 5:24 cmd.exe and file name conversion from comman line argument h_ono 2018-07-27 6:56 ` Marco Atzeri 2018-07-27 7:27 ` Andrey Repin @ 2018-07-27 8:08 ` Brian Inglis 2018-07-27 9:15 ` h_ono 2 siblings, 1 reply; 8+ messages in thread From: Brian Inglis @ 2018-07-27 8:08 UTC (permalink / raw) To: cygwin On 2018-07-26 18:56, h_ono@ot.olympus.co.jp 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: cmd.exe and file name conversion from comman line argument 2018-07-27 8:08 ` Brian Inglis @ 2018-07-27 9:15 ` h_ono 2018-07-27 10:16 ` h_ono 2018-07-27 15:16 ` Takashi Yano 0 siblings, 2 replies; 8+ messages in thread From: h_ono @ 2018-07-27 9:15 UTC (permalink / raw) To: cygwin [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2750 bytes --] Thank you > From: Marco Atzeri <marco.atzeri@gmail.com> > what happen if you use bash ? With cmd + bash, the problem does not occur, but I would like to use cmd without bash, if possible. > From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca> > To: cygwin@cygwin.com > Date: 2018/07/27 14:25 > Subject: Re: cmd.exe and file name conversion from comman line argument > Sent by: cygwin-owner@cygwin.com > 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. Thank you. quoting only the space character worked, which seems to solve my problem. from cmd, with LANG environment variables set to ja_JP.UTF-8 c:\cygwin\home\hiroo> touch ãã" "ã or c:\cygwin\home\hiroo> touch ãã' 'ã gives a file named ãã ã. The rest may be superfluous, but just to compare with. Quoting Japanese characters too did not work. c:\cygwin\home\hiroo> touch "ããã" gives c:\cygwin\home\hiroo> ls '"ããã"' (and shown as ã»ãããã» in explorer) while c:\cygwin\home\hiroo> touch "aaa" gives c:\cygwin\home\hiroo> ls aaa Doing c:\cygwin\home\hiroo> echo > "ããã" (in this case, the file name is surely processed by cmd) gives a file named ããã (without quotes). > 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 > --------- Hiroo Ono \x03BKCB\x1cØ\x19[H\x1c\^[Ü\x1cÎ\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÜ\x1cØ\x19[\Ë\x1d^[[\x03BTN\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÙ\KÃB^[ØÝ[Y[\x18]\x1a[Û\b\b\b\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÙ^[ØÜË\x1d^[[\x03B[ÝXØÜXH\x1a[Î\b\b\b\b\b\x1a\x1d\x1d\x1c\x0eËØÞYÝÚ[ÛÛKÛ[\vÈÝ[ÝXØÜXK\Ú[\^[\x19CBB ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: cmd.exe and file name conversion from comman line argument 2018-07-27 9:15 ` h_ono @ 2018-07-27 10:16 ` h_ono 2018-07-27 15:16 ` Takashi Yano 1 sibling, 0 replies; 8+ messages in thread From: h_ono @ 2018-07-27 10:16 UTC (permalink / raw) To: cygwin [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 1291 bytes --] > From: Hiroo Ono/jp/olympus@olympus > To: cygwin@cygwin.com > Date: 2018/07/27 15:57 > Subject: Re: cmd.exe and file name conversion from comman line argument > Sent by: cygwin-owner@cygwin.com > > c:\cygwin\home\hiroo> touch "ããã" > > gives > > c:\cygwin\home\hiroo> ls > '"ããã"' It may be related to build_argv() in https://github.com/mirror/newlib-cygwin/blob/master/winsup/cygwin/dcrt0.cc line 320 to 328: /* Skip over characters until the closing quote */ { sawquote = cmd; /* Handle quoting. Only strip off quotes if the parent is a Cygwin process, or if the word starts with a '@'. In this case, the insert_file function needs an unquoted DOS filename and globbing isn't performed anyway. */ cmd = quoted (cmd, winshell && argc > 0 && *word != '@'); } As the comment says, c:\cygwin\home\hiroo> touch @"ããã" gives file named @ããã. --------- Hiroo Ono \0ТÒÐÐ¥\a&ö&ÆVÒ\a&W\x06÷'G3¢\x02\x02\x02\x02\x02\x02\x06GG\x03¢òö7wvâæ6öÒ÷\a&ö&ÆV×2æFÖÀФd\x15\x13¢\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02\x06GG\x03¢òö7wvâæ6öÒöf\x17\x12ðФFö7VÖVçF\x17Föã¢\x02\x02\x02\x02\x02\x02\x02\x02\x06GG\x03¢òö7wvâæ6öÒöFö72æFÖÀÐ¥Vç7V'67&&R\x06æfó¢\x02\x02\x02\x02\x02\x06GG\x03¢òö7wvâæ6öÒöÖÂò7Vç7V'67&&R×6×\x06ÆPÐ Ð ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: cmd.exe and file name conversion from comman line argument 2018-07-27 9:15 ` h_ono 2018-07-27 10:16 ` h_ono @ 2018-07-27 15:16 ` Takashi Yano 2018-07-30 10:54 ` h_ono 1 sibling, 1 reply; 8+ messages in thread From: Takashi Yano @ 2018-07-27 15:16 UTC (permalink / raw) To: cygwin On Fri, 27 Jul 2018 15:56:39 +0900 > The rest may be superfluous, but just to compare with. > Quoting Japanese characters too did not work. > > c:\cygwin\home\hiroo> touch "あああ" > > gives > > c:\cygwin\home\hiroo> ls > '"あああ"' If you set LANG prior to touch using set instead of env, it seems to behave as you expected. C:\cygwin\home\yano\testdir>set LANG=ja_JP.UTF-8 C:\cygwin\home\yano\testdir>touch "あああ" C:\cygwin\home\yano\testdir>ls あああ C:\cygwin\home\yano\testdir>dir Volume in drive C has no label. Volume Serial Number is 1E17-C0B1 Directory of C:\cygwin\home\yano\testdir 2018/07/27 19:06 <DIR> . 2018/07/27 19:06 <DIR> .. 2018/07/27 19:06 0 あああ 1 File(s) 0 bytes 2 Dir(s) 89,141,444,608 bytes free -- Takashi Yano <takashi.yano@nifty.ne.jp> -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: cmd.exe and file name conversion from comman line argument 2018-07-27 15:16 ` Takashi Yano @ 2018-07-30 10:54 ` h_ono 0 siblings, 0 replies; 8+ messages in thread From: h_ono @ 2018-07-30 10:54 UTC (permalink / raw) To: cygwin hello, > From: Takashi Yano <takashi.yano@nifty.ne.jp> > To: cygwin@cygwin.com > Date: 2018/07/27 19:16 > Subject: Re: cmd.exe and file name conversion from comman line argument > Sent by: cygwin-owner@cygwin.com > If you set LANG prior to touch using set instead of env, > it seems to behave as you expected. > > C:\cygwin\home\yano\testdir>set LANG=ja_JP.UTF-8 > > C:\cygwin\home\yano\testdir>touch "あああ" > > C:\cygwin\home\yano\testdir>ls > あああ Confirmed. Thank you. I thought using env and setting environment variable were identical. Sorry. ---------- Hiroo Ono -- 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 ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-07-30 1:52 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-07-27 5:24 cmd.exe and file name conversion from comman line argument h_ono 2018-07-27 6:56 ` Marco Atzeri 2018-07-27 7:27 ` Andrey Repin 2018-07-27 8:08 ` Brian Inglis 2018-07-27 9:15 ` h_ono 2018-07-27 10:16 ` h_ono 2018-07-27 15:16 ` Takashi Yano 2018-07-30 10:54 ` h_ono
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).