Conditional execution (Test) not working as expected

Dear forum members,

after using fvwm2 for 25+ years, I’ve recently switched to fvwm3 1.0.6a, and I’m trying to introduce some customization to my config file for the first time. In the RestartFunction I’d like to execute a command if a certain condition is met.

The line

  • I Exec xterm -geometry 80x10+0-0

works fine. But if I change it to

  • I Test (EnvMatch $[infostore.startXMessages] 1) Exec xterm

nothing happens. When I check the condition with

  • I Echo Test (EnvMatch $[infostore.startXMessages] 1) Exec xterm

the output to the log file is

CMD_Echo: Test (EnvMatch 1 1) Exec xterm

confirming that $[infostore.startXMessages] contains the expected value.

Can somebody please explain to me what I’m doing wrong here?

Your syntax is incorrect, according the manual page you don’t use an $ in your variable name. So it should be something like:

Test (EnvMatch infostore.startXMessages 1) Exec exec xterm

The code notices that the variable name starts with infostore., then looks up the value of startXMessages in the infostore database.

I have tested this and it still isn’t working (digging further), but the first issue was your syntax.

Dear somiaj,
thanks a lot for looking at my code and pointing out my mistake! In fact, I started with an environment variable and changed it to a local infostore variable, hoping that it might give me less trouble. It is quite sobering to learn that I went from bad to worse by introducing an extra mistake. But I still have no clue why the command after the test isn’t executed.

I’ve found a solution to my problem.
What I wanted to do is execute a command / program in the restart function only the first time the restart function is called. My idea was to check the process list for an entry of the program (with ps -ef | grep ).
When Test (EnvMatch [infostore.variable] 1) didn’t work, I tried an environment variable next.
For the environment variable EnvMatch worked fine, but unfortunately the ps / grep pipe executed in PipeRead didn’t give me the same results as my Bourne shell script containing these commands – afaIk PipeRead uses Bourne shell syntax, but unfortunately it didn’t work this way for me.
So I abandoned the approach and instead used an undefined variable for Test (!EnvIsSet Variable) as the condition to execute the command and in the next line I said SetEnv Variable. This gave me the desired effect of command execution only once.
However, I’d still like to understand why my first two approaches didn’t succeed.

EnvMatch will only run if the variablename you provide it exists and its value is equal to the value you want it to be (up to wild cards). So the test will fail in all other cases. The problem with Test (EnvMatch $[infostore.startXMessages] 1) Exec xterm is that the expansion happens at the time the code is read, so as you noted you are really using the command Test (EnvMatch 1 1), but there is no environment variable named 1, and thus it cannot check what its value is.

Thank you again for your answer. Unfortunately I still don’t understand how this can be made to work. If an environment variable is substituted by its value at the time when the code is read and then the value is treated as an undefined variable this kind of match of a variable to a number / an expected value of the variable seems futile. What is the intention of the EnvMatch function and how can it be used in such a fashion that the test / match actually works the way suggested by the name EnvMatch?