I used the fact that Morrowind stores Global longs(int32) as floats. This means that do no span the entire 32-bit space and have a smaller limit. First I declare a global 'openmwchecker'. The I use the following script

Begin openmwtest
set openmwchecker to 2147483521 ;this is one larger than the actual limit Morrowind can handle but OpenMW manages
if (openmwchecker == 2147483521)
MessageBox, "OpenMW"
else
MessageBox, "Morrowind"
endif
End

The used branches can ofcourse be used to set a real global variable to indicate if you are running Morrowind or OpenMW and act accordingly.

Woudln't it be possible for OpenMW to inject an environment variable so that scripts can check the engine and even version?

are you referring using version specifig behaviour for mods .?
if some feature got support as a mod and labeled as bug that will need to see case by case. flying fishes and ribbing clothing from all in vardenfell were read but went down as bugs .p
there shouldn't be any resrictions on distributiing older openmw version with mod...

I am not going that far, I am just thinking in something like checking for `CYGWIN_VERSION` env var to see if your are running in Cygwin or another Bash. Version of course should not be used to support backward compatibility.

My opinions are my own. I am just a thankful user of OpenMW with no affiliation with the dev team.

I was actually wondering if a standardised way of telling Morrowind and OpenMW apart to make Morrowind mods compatible with OpenMW.

OpenMW should already be compatible with Morrowind mods. If you found a situation where it isn't, it's likely a bug and should be reported. Trying to work around it in the mod will potentially cause more problems or confusion as OpenMW continues to improve compatibility.

There are a lot of things that probably won't ever get fixed, like actors being able to move freely when already inside of a piece of geometry, which some mannequins in some mods accidentally do and vibrate like hell in OpenMW because of it.

Perhaps, though that's a more general issue in the mod that can be fixed to work in both (i.e. moving it out of the geometry), without having to differentiate between OpenMW and vanilla. The actual number of cases where OpenMW is willfully different with vanilla-compatible content is relatively quite small, and even then is generally to fix something that didn't work in vanilla to begin with (e.g. accessing unloaded object instances, or being able to use a variable in places where vanilla needs a constant).

How about TES3MP?
I know at least of this mod (https://www.nexusmods.com/skyrim/mods/76455/) that will benefit from knowing exactly where it runs. Right now it offers two version depending on whether you are in MP or normal OpenMW. Having a way to distinguish would allow for a a more simple installation.

I know, someone may say that after 1.0 Multiplayer will be merged into master, but imho, it does not hurt to provide this feature right in the meantime.

My opinions are my own. I am just a thankful user of OpenMW with no affiliation with the dev team.

How about TES3MP?
I know at least of this mod (https://www.nexusmods.com/skyrim/mods/76455/) that will benefit from knowing exactly where it runs. Right now it offers two version depending on whether you are in MP or normal OpenMW. Having a way to distinguish would allow for a a more simple installation.

I know, someone may say that after 1.0 Multiplayer will be merged into master, but imho, it does not hurt to provide this feature right in the meantime.

I have to agree with David there, TES3MP should not do this and not sure the method is the best solution, it is too specific for my taste.
However, seeing a 100% parity with vanilla is impossible and other forks may appear, for me it is clear that OpenMW should provide a generic method to identify the engine so modders can add fixes, warnings or configuration options.

My opinions are my own. I am just a thankful user of OpenMW with no affiliation with the dev team.