Author Topic: cb_console_runner argument bug  (Read 7406 times)

Offline Code::Blocks_bug

  • Single posting newcomer
  • *
  • Posts: 2
cb_console_runner argument bug
« on: February 22, 2011, 04:19:57 am »
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.

« Last Edit: February 22, 2011, 04:23:45 am by Code::Blocks_bug »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: cb_console_runner argument bug
« Reply #1 on: February 22, 2011, 12:11:40 pm »
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]"'

Offline Code::Blocks_bug

  • Single posting newcomer
  • *
  • Posts: 2
Re: cb_console_runner argument bug
« Reply #2 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?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: cb_console_runner argument bug
« Reply #3 on: February 23, 2011, 03:12:13 pm »
Hmm...awesome. :D That worked.
Thanks.

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

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.

Offline pirx67

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: cb_console_runner argument bug
« Reply #4 on: February 26, 2011, 11:28:50 pm »
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.

Quote
Patches 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.
« Last Edit: February 26, 2011, 11:31:26 pm by pirx67 »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: cb_console_runner argument bug
« Reply #5 on: February 27, 2011, 06:45:54 pm »
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.


Offline pirx67

  • Multiple posting newcomer
  • *
  • Posts: 40
Re: cb_console_runner argument bug
« Reply #6 on: March 01, 2011, 01:08:40 am »
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