News:

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

Main Menu

Set programs' arguments does not work on Windows CodeBlock

Started by vahalia, October 23, 2020, 02:02:30 AM

Previous topic - Next topic

vahalia

I am using CB on Windows, and my program takes a few arguments. I am trying to set these arguments through Project->Set Programs' Arguments dialog. When my argument string contains a "$" character, strange things happen. Specifically, my argument string is
  2 5 $1N $1N-2HDont
When I run the program, the first two arguments appear correctly in argv[], but the third one is a blank, and the fourth gets changed to -2HDont
Looks like some kind of strange wildcard processing. Can someone explain what is going on and how to work around it? I tried enclosing the args in single quotes or preceding the $ with a backslash, but that too resulted in strange behavior.

Pecan

Quote from: vahalia on October 23, 2020, 02:02:30 AM
I am using CB on Windows, and my program takes a few arguments. I am trying to set these arguments through Project->Set Programs' Arguments dialog. When my argument string contains a "$" character, strange things happen. Specifically, my argument string is
  2 5 $1N $1N-2HDont
When I run the program, the first two arguments appear correctly in argv[], but the third one is a blank, and the fourth gets changed to -2HDont
Looks like some kind of strange wildcard processing. Can someone explain what is going on and how to work around it? I tried enclosing the args in single quotes or preceding the $ with a backslash, but that too resulted in strange behavior.

$ is used as a macro prefix in CB. It must be being interpreted incorrectly by the macros manager.

I'll try to recreate the problem

Pecan

I can replicate the problem.
Until I can find a fix, just prefix two extra $'s in front of the current $.
Like: 2 5 $$$1N $$$1N-2HDont
as a temporary work around.

vahalia


Pecan


oBFusCATed

Are you sure this won't break something?
For example if someone expects that unset variables are replaced with empty strings?

I think a better solution is to define some clear way to escape this character. Like doing "\$myNotVar"or doing "$$myNotVar"...
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

MortenMacFly

Quote from: oBFusCATed on October 25, 2020, 10:15:26 AM
Are you sure this won't break something?
I'm afraid it did break something, please check the nightlies reports.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

J.

Two comments:

@vahalia: Why not using another initial tag to avoid that other shells your program is called from are confused because of variable expansion, e.g. replace '$' by '#' or something else?

@Pecan et al.: Why not rather allowing variable names to start with [a-z] only?

m_RE_Unix.Compile(_T("([^$]|^)(\\$[({]?(#?[a-z][a-z_0-9.]*)[)} /\\]?)"),               wxRE_ICASE | wxRE_EXTENDED | wxRE_NEWLINE);   

Quote from: Pecan on October 24, 2020, 03:56:23 PM
fixed: head r12214
Just for the record: reverted in r12228.