News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

cb_console_runner argument bug

Started by Code::Blocks_bug, February 22, 2011, 04:19:57 AM

Previous topic - Next topic

Code::Blocks_bug

Hello,
I just uncovered a bug in the cb_console_runner program, which prevents certain arguments from being passed, even if the arguments are supported by your program.  :lol: Or more accurately, it allows the arguments to be passed, but it *ucks them up first and they never get passed to your (my) program correctly.  :shock:

Read more on this issue here, a thread which I started on the Ubuntu forums after originally thinking the issue was with xterm, but according to user "gmargo", it is a problem in cb_console_runner.


Jenna

As far as I see, it's not as easy as gmargo writes.

execvp would work, but we do not get the return value of the running program, only the return value of execvp.
At least I did not find an easy way to get them.

As Workaround you can try to put single-quotes (here in red) around your doublequoted strings in the programs arguments:
Quote/home/gorilla/Documents/C_html4_elements.h '"[string;desc]"' '"[C_html_element;element]"'

Code::Blocks_bug

Hmm...awesome. :D That worked.
Thanks.

Just to wrap this issue up, any plans to fix the bug?

Jenna

Quote from: Code::Blocks_bug on February 23, 2011, 03:10:03 AM
Hmm...awesome. :D That worked.
Thanks.

Just to wrap this issue up, any plans to fix the bug?

Quote from: jens on February 22, 2011, 12:11:40 PM
execvp would work, but we do not get the return value of the running program, only the return value of execvp.
At least I did not find an easy way to get them.

As said it's not as easy and it has not the highest preference at the moment, but I try to keep it in mind.
Patches are welcome of course.

pirx67

#4
Hi Jens,

I've read this thread and was interested in the internals of cb_console_runner. I've had a look at the source code and now I'd like to contribute some code.

QuotePatches are welcome of course.

Have a look at the attached file which is a rewritten version of ConsoleRunner/main.cpp. :)

My main goal was to avoid the call of system() to avoid that the command line will be evaluated by the system's standard shell a second time. To achieve this under Linux the exec*() functions family provides some means.

For *nix I give the <argv> array directly to execv() to avoid the need to fiddle around with quoting for the arguments again.

Therefore the code to glue together a new command line from the <argv> contents is now only present in the Windows branch of the code. The code still worked so far (tested under WinXP).

:idea: But I have an idea to get around this, too. (Not implemented nor tested so far). I would get the whole Windows command line with GetCommandLine() and then cut off the contents of argv[0] from the result (if needed including quotes). But the rest of the command line is then like it has been given to cb_console_runner and could be given to the CreateProcess() call as is. This avoids
to introduce any quoting issues through cb_console_runner.

Any comments are appreciated. Perhaps somebody of the more Windows aware developers may comment on my idea for the Windows branch?

pirx67

PS.: If PRINT_ARGS is defined then for debugging purposes the currently given arguments are
printed. This part of code should be removed for a release version.

Jenna

It does not work in real world.
I only tested it on the commandline, but if C::B sends the command to cb_console_runner[.exe], it preprends "LD_LIBRARY_PATH=..." on linux to be able to find the needed libs.
This will of course not work.


pirx67

Well,

I should have tested till the end and replace cb_console_runner of my installation with my own program. That shows again: Never trust the documentation  :o

pirx67