Author Topic: Set programs' arguments does not work on Windows CodeBlock  (Read 5758 times)

Offline vahalia

  • Multiple posting newcomer
  • *
  • Posts: 14
Set programs' arguments does not work on Windows CodeBlock
« 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.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: Set programs' arguments does not work on Windows CodeBlock
« Reply #1 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

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: Set programs' arguments does not work on Windows CodeBlock
« Reply #2 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.

Offline vahalia

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: Set programs' arguments does not work on Windows CodeBlock
« Reply #3 on: October 24, 2020, 12:26:38 am »
Thanks. Will try that.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2750
Re: Set programs' arguments does not work on Windows CodeBlock
« Reply #4 on: October 24, 2020, 03:56:23 pm »
fixed: head r12214

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Set programs' arguments does not work on Windows CodeBlock
« Reply #5 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"...
(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!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Set programs' arguments does not work on Windows CodeBlock
« Reply #6 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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline J.

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: Set programs' arguments does not work on Windows CodeBlock
« Reply #7 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.