I am running a C code from sublimetext 3 with GCC on Windows 10 and I would like the external cmd to show exit code after running the exe.
Here is my sublime-build file:
{
"shell_cmd" : "gcc -Wall -pedantic $file_name -o ${file_base_name}",
"working_dir" : "$file_path",
"variants":
[
{
"name": "Run",
"shell_cmd": "gcc -Wall -pedantic $file_name -o ${file_base_name} && start cmd /k ${file_path}/${file_base_name} "
}
]
}
I've tried something like this:
"shell_cmd": "gcc -Wall -pedantic $file_name -o ${file_base_name} && start cmd /k ${file_path}/${file_base_name} & echo %errorlevel% "
The problem with this one is that the exit code is showing up in the sublimetext shell, always displaying 0. I guess it's the external cmd exit code.
I would like the echo %errorlevel% part to be executed in the new cmd and to display my exe's exit code but I can't figure out how to do it.
EDIT : Here is a screenshot :
My main.exe runs in a new cmd and the echo is done back in sublimetext's own console.
I guess these questions sum it up in a better way :
1- How do I write this script so that cmd can execute a second command ?
2- How do I make it open, run my .exe, and only then display the exit code ?
EDIT 2 :
Here you can see my code and the external cmd called by sublimetext's internal cmd with the command from my sublime-build file.
I manually entered echo %errorlevel%into this external cmd.
The goal I'm trying to achieve is to modify the command from my sublime-build file, which will be executed from sublimetext's internal cmd, in such a way that the external cmd called runs my code and only then evaluate echo %errorlevel%, all of this automatically.