Code::Blocks Forums
User forums => Using Code::Blocks => Topic started 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.
-
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
-
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.
-
Thanks. Will try that.
-
fixed: head r12214
-
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"...
-
Are you sure this won't break something?
I'm afraid it did break something, please check the nightlies reports.
-
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.