Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious "/title" in initial command line #2820

Closed
4 tasks done
duncairn opened this issue Jan 30, 2023 · 9 comments
Closed
4 tasks done

Spurious "/title" in initial command line #2820

duncairn opened this issue Jan 30, 2023 · 9 comments

Comments

@duncairn
Copy link

duncairn commented Jan 30, 2023

Version Information

Cmder version: 1.2.31
Operating system: Windows 7x64 SP1

Cmder Edition

Cmder Full (with Git)

Description of the issue

I have a task which initially calls a setup .bat file.

-cur_console:d:G:\ESP32\idf4.2\esp-idf cmd /k ""G:\ESP32\dev.espressif\idf_cmd_init.bat" "G:\Python" "G:\Tools\Git\cmd""

Within that file is the following line:
if "%~2"=="" (

If I call Cmdr with that task as the argument (that is, this is the initial task) the .bat fails with "The syntax of the command is incorrect" at that line. The displayed output from the .bat is:
G:\ESP32\idf4.2\esp-idf>if "G:\Tools\Git\cmd"" /title "Cmder"=="" (

If I start Cmdr with the default task, and then start this task in a new tab, it works perfectly and the output of that line is:
G:\ESP32\idf4.2\esp-idf>if "G:\Tools\Git\cmd" == "" (

If I switch Cmder.exe for a previous version (V1.3.14, which is what I used before) there is no problem.

How to reproduce

No response

Additional context

No response

Checklist

  • I have read the documentation.
  • I have searched for similar issues and found none that describe my issue.
  • I have reproduced the issue on the latest version of Cmder.
  • I am certain my issues are not related to ConEmu, Clink, or other third-party tools that Cmder uses.
@DRSDavidSoft
Copy link
Contributor

@duncairn Can you please attach your ConEmu.xml or user_ConEmu.xml in Cmder so we can investigate? Firstly please check if the file that you attach contains the ESP32 IDF task, thanks.

@duncairn
Copy link
Author

ConEmu.xml attached.
ConEmu.zip

@chrisant996
Copy link
Contributor

chrisant996 commented Feb 10, 2023

What is esp-idf in the -cur_console:d:G:\ESP32\idf4.2\esp-idf cmd /k ""G:\ESP32\dev.espressif\idf_cmd_init.bat" "G:\Python" "G:\Tools\Git\cmd""?

My guess would be that esp-idf is parsing the part ""G:\ESP32\dev.espressif\idf_cmd_init.bat" "G:\Python" "G:\Tools\Git\cmd"" differently than CMD does. Specifically, the "" might be getting turned into " (or removed) before the cmd /k is launched. I suspect that because that would indeed cause the final "" to end up being considered part of %2.

UPDATE: never mind -- the -cur_console:d: flag specifies a directory, so esp-idf is part of a directory name, not a program.

@duncairn
Copy link
Author

Yes :)
Just to confirm, I changed the folder to 'esp_idf' but it didn't fix it.

@chrisant996
Copy link
Contributor

chrisant996 commented Feb 10, 2023

deleted

@duncairn
Copy link
Author

duncairn commented Feb 10, 2023

I would have put this down to cmd parsing the quotes a bit funnily, but there are two things that caused me to think it's not that:

  1. The presence of '/title "Cmder"' on the command line - presumably that's aimed at ConEmu and shouldn't make it to the final command.
  2. It only occurs with the new Cmder. exe - using the older version is fine.

I changed the command line to call a simple test.bat instead:

-cur_console:d:G:\ESP32\idf4.2\esp-idf cmd /k ""R:test.bat" "G:\Python\" "G:\Tools\Git\cmd\""

The contents of test.bat are:
echo 0: %0, 1: %1, 2: %2, 3: %3, 4: %4

The result of the new version Cmder.exe:
0: "R:test.bat", 1: "G:\Python\", 2: "G:\Tools\Git\cmd\"" /title "Cmder, 3: , 4:

And the old version Cmder.exe:
0: "R:test.bat", 1: "G:\Python\", 2: "G:\Tools\Git\cmd\", 3: , 4:

That, to me, implies that something has changed in Cmder.exe to cause this. Could it have been a side effect of #2752 (comment)

@chrisant996
Copy link
Contributor

@DRSDavidSoft this is a bug in the Cmder launcher:

Here is the code:

CmderLauncher.cpp

@@  -427,14  +428,19  @@
 	if (!streqi(cmderTask.c_str(), L""))
 	{
 		swprintf_s(args, L"%s /run {%s}", args, cmderTask.c_str());
 	}
 
+	if (!streqi(cmderTitle.c_str(), L""))
+	{
+		swprintf_s(args, L"%s /title \"%s\"", args, cmderTitle.c_str());
+	}
+
 	if (cfgRoot.length() != 0)
 	{
 		swprintf_s(args, L"%s  -loadcfgfile \"%s\"", args, userConEmuCfgPath);
 	}
 
 	if (!streqi(cmderConEmuArgs.c_str(), L""))
 	{
 		swprintf_s(args, L"%s %s", args, cmderConEmuArgs.c_str());
 	}

But the ConEmu documentation states about the /run switch that "This must be the last used switch (excepting -new_console and -cur_console)."

So the Cmder launcher is appending /title and -loadcfgfile in an incorrect position in the command line.

Depending on what cmderConEmuArgs.c_str() can contain, it may be getting appended in an incorrect position as well.

@duncairn
Copy link
Author

Thanks very much, @chrisant996

@DRSDavidSoft
Copy link
Contributor

@chrisant996 Hi there, thanks for the investigation and the fix, this issue has been closed by #2806. Sorry I've been super busy these couple of weeks, will be back for the other fixes soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants