understanding the purpose of <If env | grep -q $EXAMPLE>

I have seen this code in a few places and my understanding is they are using it to determine what app called the script.

I have a script that is called by two different applications and what it to do one thing when called by one and something else when called by the other. How do I determine what app is calling the script? If my example is correct how would I determine the $EXAMPLE and is every running application assigned a variable name?

I thought about just writing a separate script but the script is caching some info from one app and then echoing out to the other app when it asks for it so I think it should stay as one script.

Any help or pointing me in the correct direction would be great.
Thank you,
Jason

Please become accustomed to supplying decent and sufficient information whereupon an analysis can be started. Like contents of the EXAMPLE variable, the (meaningful) code around that if construct, your OS and shell versions.
None of your conclusions above can be acknowledged nor disproved due to lack of info. The construct you show checks the process environment to see if it contains the string which is the expanded value of EXAMPLE , be it (part of) a variable name or an assignment string.

1 Like