Octave: prblm when launching from within shell script

MAC Catalina: 10.15.4
Several versions on ‘octave’ on the system

octave octave-5.2.0 octave-cli-4.0.3 octave-config octave-config-5.2.0 octave-4.0.3 octave-cli octave-cli-5.2.0 octave-config-4.0.3

Pblm: From a bash shell the cmd ‘octave’ launches an outdated version of the program. When I add an alias to my .bashrc

alias octave=’/usr/local/bin/octave-5.2.0’

it launches the current version (e.g.5.2.0). However, when I issue the same command within a script it trys to launch the outdated version “octave” which will not run without some legacy java runtime.

From a bash CLI the command ‘which octave’ returns


octave is aliased to `/usr/local/bin/octave-5.2.0’
octave is /opt/local/bin/octave
octave is /usr/local/bin/octave
octave is /usr/local/bin/octave
octave is /usr/local/bin/octave


and the command ‘octave’ launches with
!!!
GNU Octave, version 5.2.0
Copyright © 2020 John W. Eaton and others.
!!!

But this file:

echo ${SHELL}
which octave
octave

generates the following output
^^^^^^^^^^^^^
/bin/bash
/opt/local/bin/octave
No Java runtime present, requesting install.
^^^^^^^^^^^^
And a dialog box:
“To open “this Java application” you need to install the legacy HJava SE 6 runtime.”

However with this shell script:

echo ${SHELL}
which octave
octave-5.2.0

launches the current version of octave.

So an alias in .bashrc does not solve the problem. I could change the calls in all of my scripts but that is a maintenance nightmare.

Another weirdness – I also have a MacBook Pro (same OS rev) and this problem does not occur.

Maybe the brew formula changed in the time b/w my upgrading of the two machines(?).