Function to do something as well as set env variable

Hi all:

I want a function, whose pseudo code looks like the following:

if(window_name == foo && my_env_var == true) {
     set my_env_var = false;
     call funcFoo_a();
}
else {
    call funcFoo_b();
}

funcFoo_a() {}

funcFoo_b(){}

the problem is, I am not sure how to make that work in BASH scripting, and use it from a PipeRead.

Below is my attempt (incomplete) to make it work. Any suggestions would be greatly appreciated.

AddToFunc FuncTest
+ I PipeRead `[ $[w.name] = "foo" -a "$[MY_ENV_VAR]" == "TRUE"] && \
echo SetEnv MY_ENV_VAR FALSE && echo funcFoo_a ||\
echo func_Foo_b`

So far, nothing seems to be working…

any suggestions?

thanks in advance,
Skender

Shell mechanics. :slight_smile: Spaces are everything:

[code]

  • I PipeRead [ $[w.name] = "foo" -a "$[MY_ENV_VAR]" == "TRUE" ] && \ echo SetEnv MY_ENV_VAR FALSE && echo funcFoo_a || \ echo func_Foo_b[/code]

You could also do:

+ I PipeRead `[ $[w.name] = "foo" ] && [ $[my_env_var] == "foo" ] \
&& echo SetEnv .... || echo ......`

– Thomas Adam

Thanks Thomas.

I think I’ll go kill myself now :slight_smile: