msys2 / MSYS2-packages

Package scripts for MSYS2.
https://packages.msys2.org
BSD 3-Clause "New" or "Revised" License
1.29k stars 490 forks source link

[BUG] specific comment form in msys2_shell.cmd causes terminal launch failure #2075

Open earthbound19 opened 4 years ago

earthbound19 commented 4 years ago

I'm not sure where the correct repository or place is to report this issue. I'm happy to report it elsewhere if wanted. Also, if it's a non-issue it doesn't matter to me (and I'm happy if it's closed without solving it). I'm reporting it for the chance that it may matter.

Describe the bug

I am probably the only person on Earth who has or will encounter this particular bug, as it results in modifications to msys2_shell.cmd which possibly I only have made. Even so, I'm reporting it as it may indicate potential other issues.

If a comment of a very particular form exists in the msys2_shell.cmd file, the MSYS2 terminal fails to launch, with error code 126.

Steps to Reproduce the Problem

rem To export full current PATH from environment into MSYS2 use '-use-full-path' parameter
rem or uncomment next line

Becomes this:

:: To export full current PATH from environment into MSYS2 use '-use-full-path' parameter
:: or uncomment next line

Instead of luanching the MSYS2 terminal, it stops with this error:

C:\msys64: C:\msys64: Is a directory
/usr/bin/bash: Exit 126.

I isolated the problem to what seems to be a very particular form of (modified) comment on these two lines in msys2_shell.cmd:

  :: Increment msys2_shiftCounter by number of words in argument (as cmd.exe saw it).
  :: (Note that this form of FOR IN loop uses same delimiters as parameters.)

With those parenthesis around the second line of that comment block, this error occurs. But if I remove the parenthesis, like this:

  :: Increment msys2_shiftCounter by number of words in argument (as cmd.exe saw it).
  :: Note that this form of FOR IN loop uses same delimiters as parameters.

Then msys2_shell.cmd launches the MSYS2 terminal without error.

It gets even weirder.

A comment demarker by itself with two colons :: and then a comment in parenthesis, like this, by itself:

  :: (comment)

Will not cause this error.

No, it has to come immediately after a comment with characters not surrounded by parenthesis:

  :: comment
  :: (comment)

It seems moreover that having a closing parenthesis anywhere on a comment immediately following another comment is what the issue pattern may be.

Additional Context: Operating System, Screenshots

Duplicated on Windows 7 Professional (last release fully up to date with all patches) and Windows Home v10.0.18363 Build 18363.

gsal commented 4 years ago

msys2-x86-64-20200555.exe installed into Windows 10. Replaced all "rem" with "::" in msys2_shell.cmd file... Do not get any error message, things works just the same. My 2 cents.

tanzislam commented 4 years ago

According to SS64 there are a few differences between REM and ::. Guess you can add to that research. :slightly_smiling_face: