ConEmu icon indicating copy to clipboard operation
ConEmu copied to clipboard

Issue with argument string ending with `\`

Open lucatrv opened this issue 3 years ago • 3 comments

Versions

ConEmu build: 210912 x32/x64 OS version: Windows 10 x64 Used shell version: Clink 1.1.45.1c3985

Problem description

When an argument string ends with \, and it is wrapped between " (this happens by default for paths containing spaces in Windows), it is passed as a string ending with ".

Steps to reproduce

  1. Write a bash script which prints all input arguments with command echo $@
  2. Run it passing a Windows path with spaces, for instance: bash script.sh "c:\test\path with spaces\"

Actual results

Output is c:\test\path with spaces"

Expected results

Output should be c:\test\path with spaces

lucatrv avatar Aug 06 '22 12:08 lucatrv

You have quite an obsolete version. Have you tried newer builds?

Maximus5 avatar Aug 07 '22 22:08 Maximus5

That's the stable version included by default in Cmder. I now tried with the preview version 220418, and then with the latest alpha version 220807, and they all behave the same.

lucatrv avatar Aug 08 '22 07:08 lucatrv

This is not a ConEmu or Cmder issue. This is part of Windows.

You are running bash script.sh "c:\test\path with spaces\" on Windows from a CMD shell. The bash is actually bash.exe which is a Windows wrapper program that starts the WSL and then runs the actual Linux bash.

On Windows, \" is an escaped quote.

See these articles for more information:

  • https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-commandlinetoargvw?redirectedfrom=MSDN
  • https://docs.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way

To get the same command line processing as Linux, you would need to first start WSL explicitly, and then run bash from inside the Linux subsystem.

chrisant996 avatar Aug 30 '22 14:08 chrisant996

Ok thanks, I'm closing this issue

lucatrv avatar Dec 03 '22 18:12 lucatrv