Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: vahalia on October 23, 2020, 02:02:30 am

Title: Set programs' arguments does not work on Windows CodeBlock
Post by: 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.
Title: Re: Set programs' arguments does not work on Windows CodeBlock
Post by: Pecan on October 23, 2020, 07:05:20 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
Title: Re: Set programs' arguments does not work on Windows CodeBlock
Post by: Pecan on October 23, 2020, 10:17:40 pm
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.
Title: Re: Set programs' arguments does not work on Windows CodeBlock
Post by: vahalia on October 24, 2020, 12:26:38 am
Thanks. Will try that.
Title: Re: Set programs' arguments does not work on Windows CodeBlock
Post by: Pecan on October 24, 2020, 03:56:23 pm
fixed: head r12214
Title: Re: Set programs' arguments does not work on Windows CodeBlock
Post by: oBFusCATed on October 25, 2020, 10:15:26 am
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"...
Title: Re: Set programs' arguments does not work on Windows CodeBlock
Post by: MortenMacFly on October 25, 2020, 04:10:12 pm
Are you sure this won't break something?
I'm afraid it did break something, please check the nightlies reports.
Title: Re: Set programs' arguments does not work on Windows CodeBlock
Post by: J. on October 31, 2020, 02:30:13 pm
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);   

fixed: head r12214
Just for the record: reverted in r12228.