Can octave determine itself if it is running inside the ‘flatpak sandbox’?
I try find a method how it can determine it, but couldn’t get it done: octave_in_flatpak.m (336 Bytes)
Then if it is possible I could make it determine itself its required code depending on the case:
[s,msg]=system("flatpak-spawn --host sensors");
This seem to work in current case…
Also if octave also had itself command to check about it.
Is this some sandbox hidden files, cause I can not find it otherwise…?
But in case I have flatpak, but octave installed from snap/apt this might fail.
If I combine the both, it becomes:
# Determine whether octave is running inside the sandbox or without it...
ocinsb=~system ("flatpak-spawn --host ls > 0");
But I have no idea what the ls-command is doing here…
Isn’t that the point of this entire exercise? A test that passes inside Flatpak and fails outside?
Spawning a shell to run which flatpak-spawn certainly works, but I think it’s overkill, and it’s far less efficient. Using exist to check for the existence of a known file is orders of magnitude faster.
Use either exist ('/.flatpak-info') == 2 or exist ('/usr/bin/flatpak-spawn') == 2 if you prefer. Both are much simpler and more efficient than system ("which flatpak-spawn").